Loading jQuery, Underscore and Backbone using RequireJS 2.0.1 and shim
Date : March 29 2020, 07:55 AM
To fix this issue You only need to use "shim" config if the library does not already call define() to declare a module. jQuery does this already, so you can remove that from the shim config. The above code will work as is, but the exports shim config for jQuery will be ignored since jQuery will call define() before the shim work is done. The downsides with the shim vs having the script call define() to define a module:
|
RequireJS not working with Shim'ed jQuery plugins
Date : March 29 2020, 07:55 AM
To fix this issue The plugins almost always insist on loading before jQuery. And they should not do this due to my use of the shim setting. , Did you shim jquery too? shim: {
jQuery: {
exports: 'jquery'
},
'bootstrap': {
exports : 'jquery'
},
'select2': {
exports :'jquery'
},
...
},
|
RequireJS - why should i shim libs like jquery, backbone etc
Date : March 29 2020, 07:55 AM
Any of those help We shim because modules like jQuery and Backbone do not work in the RequireJS model .There is no define( statement defining them so they must be shimmed to work like and with real Require modules directly. Yes, what you said (just dumping them in the global namespace) works, you're not breaking any 'rules'. When you add a script tag all it does is dump the code in the global namespace - so all your modules will, in fact have access to Backbone and jQuery in the above example.
|
RequireJS and KendoUI - Shim jQuery dependency
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I'm trying to learn KendoUI and RequireJS. , I got this working, I had to change shim config: shim: {
'jQuery': {
exports: '$'
},
'underscore': {
exports: '_'
},
'handlebars': {
exports: 'Handlebars'
},
"kendo/kendo.core": {
deps: ["jQuery"]
}
}
|
RequireJS jQuery plugin shim not working?
Date : March 29 2020, 07:55 AM
Hope that helps I'm trying to get a jQuery plugin working properly with RequireJS, when using jQuery in the noconflict/noglobal state to force all modules to indicate whether they require jQuery. However, for non-AMD-friendly plugins, the shim config seems to not be working. Namely, if a jQuery plugin is defined with a wrapper like: , Just use return jQuery.noConflict( true );
return jq.noConflict( true );
(function($) {$.extend($.myPlugin, { myPlugin: { version:'0.0.1'} });})(jQuery);
require.config({
paths: {
},
map: {
'*': { 'jquery': 'jquery-private' },
'jquery-private': { 'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' }
},
shim: {
myplugins: ['jquery']
}
});
define(['jquery'], function () {
jQuery = $.noConflict(true);
return jQuery;
});
|