user626912
user626912

Reputation: 2560

Using jQuery plugins

I am trying to use some of the jQuery plugins in my project (I am using RequireJS). However I don't understand how to do it. I have tried to follow this: http://requirejs.org/docs/api.html#config-shim After what I understand it sets up a dependency of whats inside the array. I thought I could do this in a module:

define(['ui'], function($) {

}

However it does not work. What am I missing? This is from my require.config:

shim: {
        'ui': {
            'deps': ['jquery']
        },
        'tools': {
            'deps': ['jquery', 'ui']
        }
}

and paths;

'paths': {
    'jquery': 'lib/jquery/jquery',
    'ui': 'jquery/jquery-ui.min',
    'tools': 'jquery/jquery.tools.min',            
},

Upvotes: 1

Views: 168

Answers (1)

deven98602
deven98602

Reputation: 1110

requirejs.config({
'paths': {
    'jquery': 'lib/jquery/jquery',
    'ui': 'jquery/jquery-ui.min',
    'tools': 'jquery/jquery.tools.min',            
},
    shim:{
        'ui': {
            'deps': ['jquery'],
            // exports :'ui'   As they are jquery plugins they will not require exports
        },
        'tools': {
            'deps': ['jquery', 'ui'],
             //exports : 'tools'
        }
} 
});

define(['jquery'], function($) {

}

Upvotes: 1

Related Questions