How can I include jQueryUI in my modular backbone.js app using RequireJS?

后端 未结 4 1815
迷失自我
迷失自我 2020-12-09 19:05

I want to include jQueryUI in my backbone.js app using RequireJS. The main.js file included in my index.html is as follows:

require.config({
    paths: {
            


        
4条回答
  •  盖世英雄少女心
    2020-12-09 19:26

    While kujakettu's answer is at least partially correct I also had to specify jQuery as a dependancy in my shim to be sure jQuery was loaded before jQuery-UI.

    e.g.

    require.config({
        baseUrl: 'scripts/modules',
        paths:{
            jquery:'../libs/jquery',
            jqueryUI:"../libs/jquery-ui",
            underscore:'../libs/underscore',
            backbone:'../libs/backbone'
        },
        shim: {
            jqueryUI: {
                deps: ['jquery']
            },
            underscore: {
                exports: '_'
            },
            backbone: {
                deps: ["underscore", "jquery"],
                exports: "Backbone"
            },
            waitSeconds: 15
        }
    });
    

提交回复
热议问题