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 jQuery UI like this:
require.config({ deps: ["main"], paths: { "text": "lib/text" , "jquery": "lib/jquery" , "jquery-ui": "lib/jquery-ui" , "underscore": "lib/underscore" , "backbone": "lib/backbone" , "bootstrap": "lib/bootstrap" , "templates": "../templates" }, shim: { "jquery-ui": { exports: "$", deps: ['jquery'] }, "underscore": { exports: "_" }, "backbone": { exports: "Backbone", deps: ["underscore", "jquery"] }, "bootstrap": ['jquery'] } });
In the application I do:
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone) { $('div').addClass('white'); });
Unfortunately this only does the normal addClass
not the animated one from jQuery UI.
PS: I use the full jQuery edition.
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications, or you just need to add a date picker to a form control, jQuery UI is a perfect choice.
jQuery is a roughly 30 KiB dependency that nearly 84% of mobile pages used in 2021—and for good reason.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With