John Edwards
John Edwards

Reputation: 1546

RequireJS Undefined Module

I am loading JQuery and JQuery UI. For some reason JQueryUI is undefined and I cannot seem to figure out why. I know the path is correct because if I change it to an incorrect one I get a different error, so I know it is "loading" it but I cannot figure out why it is undefined. I have loaded many other modules just fine, so I don't know what the problem is. I don't see how I would be including a circular dependency, which is the only thing I have seem to found that would cause this. Thank you for any help.

Main.js

require.config({
    paths: {
        'text': '../../Scripts/RequireJS/text',     
        'jquery': "../../Scripts/JQuery/jquery-2.1.1",
        'JQueryUI': "../../Scripts/JQueryUI/jquery-ui.min",      
        'app': 'app'
    },
    shim: {
        'app': {
            deps: [ 'kendovendor']
        },
       'JQueryUI': {
            deps: ['jquery']
        }
    }
});

Then I try to load it in a view model:

define(['JQueryUI', 'jquery'], function (jqui, jq) {
    //jqui is undefined, jq is not.
    ...
}

Upvotes: 1

Views: 270

Answers (1)

Ivan Sivak
Ivan Sivak

Reputation: 7498

jQuery UI is built on top of the jQuery. I don't think you can directly call its members. Try to call some of JUI functions (for example $(..some input button.. ).button() ) and it should work. Defining your module like this should be sufficient:

define([ 
'jquery',
'JQueryUI'
], function (jq) 
{
//jq(..).button();
}

Upvotes: 3

Related Questions