6

I am trying to load JQuery-Ui with a shim, but JQueryUi keeps timing out when I try to load it even when I know 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();
}); 
});
user784756
  • 2,363
  • 4
  • 28
  • 44
  • Not sure if this is still an open question or not I haven't actually tested anything to verify, but I notice that you have an extra comma after the deps array in the jQueryUI shim. I'm guessing that would prevent the JavaScript from running properly. – CStroliaDavis Sep 27 '12 at 20:56
  • Another thing (that does not effect the success of the loading of jquery-ui), the App variable in the outmost scope (you do not use it there) is jQuery. – Trond Hatlen Oct 04 '12 at 09:00

2 Answers2

2

I think what damee is offering stands for older version of requireJs. Just folllow this tutorial as I did: Load jQuery UI with requireJS

FidEliO
  • 875
  • 3
  • 14
  • 24
0

Try to use this project https://github.com/jrburke/jqueryui-amd to translate your jqueryui to modularized version. Then you can simply 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'] 
    }
}
});

I hope this helps.

Community
  • 1
  • 1
demee
  • 582
  • 5
  • 18