How Do I Use Jquery Ui With Requirejs
I want to use jQuery UI's addClass function in my application. Beside I am using the normal jQuery, underscore, backbone all tiered together with requirejs. I have configured jQuer
Solution 1:
You need to include jquery-ui:
define(['jquery-ui', 'backbone'], function() {
$('div').addClass('white');
});
jquery should be required automatically as it is a dependency of jquery-ui
Additionally, none of these scripts return anything, but their variables are assigned to the window object. No need to assign them.
Solution 2:
try
define(['jquery', 'jquery-ui', 'underscore', 'backbone'], function($, ui, _, Backbone) {
// $.ui should be defined, but do// $.ui = ui if its not
$('div').addClass('white');
});
Solution 3:
Sometimes you only need a small subsection of jQuery UI. For example, I recently needed sortable, but if I tried to load the whole thing then I got a conflict between $.button()
on jquery-ui and $.button()
in bootstrap. jQuery UI now comes with AMD support, So I used RequireJS' build tool r.js to build exactly the subset that I needed.
Post a Comment for "How Do I Use Jquery Ui With Requirejs"