Require.js Shim for loading the jQuery UI and other jQuery packages

I am trying to load JQuery-Ui using a strip, but JQueryUi keeps timing when I try to load it, even when I know that the path is correct.

require.config({ paths: { jQuery: 'libs/jquery-wrapper', jQueryUi: 'libs/jquery-ui-min', jQuerySelectmenu: 'libs/jquery.ui.selectmenu', Underscore: 'libs/underscore-wrapper', Backbone: 'libs/backbone-wrapper', }, shim: {'Backbone': { //These script dependencies should be loaded before loading //backbone.js deps: ['Underscore', 'jQuery'], //Once loaded, use the global 'Backbone' as the //module value. exports: 'Backbone' }, 'jQueryUi': { deps: ['jQuery'], }, 'jQuerySelectmenu': { deps: ['jQuery', 'jQueryUi'] } } }); require([ 'jQuery', 'Underscore', 'Backbone', 'jQueryUi', 'jQuerySelectmenu' ], function(App) { require(['order!src/app'] , function (App) { App.initialize(); }); }); 
+6
source share
2 answers

I think damee offers for an older version of requireJs. Just follow this tutorial like me: Download jQuery user interface with requireJS

+2
source

Try using this project https://github.com/jrburke/jqueryui-amd to convert your jqueryui to the modular version. Then you can just use it:

 define(['jquery', 'jqueryui/tabs'], function($){ $('#tabs').tabs(); }); 

With requirejs config:

 requirejs.config({ paths: { 'jqueryui': '/javascript-cdn/jqueryui/' //output form jqueryui-amd }, shim: { 'jquery': { deps: [], init: function(){ return $; } }, 'jqueryui': { deps: ['jquery'] } } }); 

Hope this helps.

0
source

Source: https://habr.com/ru/post/919766/


All Articles