Start a new discussion
To start a new discussion please visit the discussions section of the GitHub home page of the project.
You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.
Re: Smartmenus will not work when Jquery is loaded by Requirejs
Home › Forums › Older releases › 0.9.x › Smartmenus will not work when Jquery is loaded by Requirejs › Re: Smartmenus will not work when Jquery is loaded by Requirejs
I’m still don’t have yet a public facing web site.
I do have a question concerning Requirejs syntax that may be outside the scope
of this forum. If it is, I understand, but just in case, let me continue!
In our business layer we have the following:
web/index.html
web/js/lib/jquery/main.js
web/js/lib/jquery/jquery-1.7.2.js (which I believe should work with smartmenus
web/js/lib/jquery/jquery.smartmenus.min.js
web/js/lib/requirePathsConfig.js (here you add require.config.js)
Note, the addition of “jquery” in the path. The requirePathsConfig.js uses slightly different format.
Below is the format of “requirePathsConfig.js”
/* js/lib/requirePathsConfig.js */
var require = require || {paths:{},shim:{}};
(function(require){
var context = "/" + location.pathname.split("/")[1] + "/";
var web = context + "web/js/";
var bl = context;
var config = {
//baseUrl: web + "js/",
paths : {
/*
* Paths lists the locations of particular scripts in web.
* These will be used with the shim config option to setup dependencies for
* each library.
*/
jquery : web + "jquery/jquery-1.7.2", /
// ** not using jquery.jqGrid-4.5.2 until fully tested with all Web features **
jqGrid : web + "jquery/plugins/webvisGridView/jquery.jqGrid-4.4.1/jquery.jqGrid.src",
jqGridLocale : web + "jquery/plugins/webvisGridView/jquery.jqGrid-4.4.1/grid.locale-en",
// Smartmenu stuff note, the different format
"jquery.smartmenus" : "jquery/jquery.smartmenus.min"
// maybe should put main.js ref here? "main" : "jquery/main",
},
shim: {
/* Hold the dependencies needed for each script. Designed to for
* RequireJS v2.0 or higher. Array holds the dependency requirements for each script above. */
// recommended from smartmenu forum
"jquery.smartmenus": {
deps: [ "jquery" ],
exports: "jQuery.fn.smartmenus"
},
jqGridLocale: ["jquery", "jqUI"],
jqGrid: ["jqGridLocale"]
}
};
//copy config into the global require
// Basically take what we have already, and append the paths/shim.
var copy = function(elementName){
for (var x in config[elementName]) {
if (config[elementName].hasOwnProperty(x)) {
require[elementName][x] = config[elementName][x];
}
}
};
//alert(paths['jquery']);
copy("paths");
copy("shim");
})(require);
// recommended from smartmenu forum requirejs([web+"jquery/main"]);
alert("finished requirePathsConfig.js");
—————————————————————————————
I tried different syntax changes. Incorporating your recommendations but still
missing something basic.
Note, also instead of using
to load say "requireConfigPaths.js" the code I see uses"
instead of
--------------------------------------------------------------------------
Can you recommend how to incorporate say "requirejs([web +"jquery/main"]) with the structure shown above?
Thank You,