1

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.
    ...
}
1

1 Answer 1

3

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();
}
Sign up to request clarification or add additional context in comments.

4 Comments

Yes, first he needs to load jquery an map it to the first parameter and than UI. Don't map UI to any parameter.
The only thing I can't figure out is why my #tabs aren't changing after the function runs. I know it is getting the object. It works when I have the code on the homepage, so I know it has something to do with RequireJS again.
You're welcome :) So I assume you're using jui tabs. I think we would need to see some code to help you figure out the issue.
I fixed it. I changed the name of my div from tabs to something else. Dunno what else was affecting it. Thanks again!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.