I have a module in RequireJS:
define(['jquery', 'jsonLoader'], function($, jsonLoader){
function buildMenu() { jsonLoader('system/models/build/menu.json', function(data){ var output=''; // ... return output; }); } return { buildMenu : buildMenu } })
After executing buildMenu()
function, it returns "undefined" (Because callback defined in jsonLoader()
does not exectuting). I'm calling to the function here:
define(["jquery", "core", "template", "jsonLoader", "debugger"], function($, core, template, jsonLoader) {
var config, debug; $(function() { jsonLoader('system/config.json',function(data){ config = data; init(); }); }); function init() { debug = new $.fn.debug; if(config.application.debug == true) debug.enabled = true // Build menu debug.log("Building Menu..."); console.log ( template.buildMenu() ); } });
And the jsonLoader looks that:
define(["jquery"],function($){
return function(name, callback){ $.get(name, function(data){ callback(data); }); };
});
Where's a mistake?