diff --git a/public/src/modules/mobileMenu.js b/public/src/modules/mobileMenu.js index c21bc5bed9..2ee74f12ad 100644 --- a/public/src/modules/mobileMenu.js +++ b/public/src/modules/mobileMenu.js @@ -5,18 +5,23 @@ define(function() { var categories = null, overlay = null, menuBtn = null, - postBtn = null; + postBtn = null, + initialized = false; function loadCategories(callback) { if (categories) { - displayCategories(); + callback(true); return; } jQuery.getJSON('/api/home', function(data) { categories = data.categories; - displayCategories(); + initialized = true; + + if (callback) { + callback(true); + } }); } @@ -65,6 +70,8 @@ define(function() { mobileMenu.onNavigate = function() { + if (initialized == false) return false; + var cid = templates.get('category_id'), tid = templates.get('topic_id'); @@ -100,9 +107,11 @@ define(function() { animateIcons(); } - - loadCategories(displayCategories); - mobileMenu.onNavigate(); + loadCategories(function() { + displayCategories(); + mobileMenu.onNavigate(); + }); + } return {