Jonathan
Jonathan

Reputation: 15432

jQuery UI not working in WordPress plugin

Simple jQuery UI functions, such as the following:

(function($) {
    $('ui').sortable();
})(jQuery);

Result in an error which would normally indicate jQuery UI was not present.

Uncaught TypeError: Object [object Object] has no method 'sortable'

However, Chrome's developer tools confirms that it has been loaded. What's up?

Upvotes: 1

Views: 545

Answers (1)

Jonathan
Jonathan

Reputation: 15432

The answer was simply to stop using jQuery shorthand. This:

(function($) {
    $('ui').sortable();
})(jQuery);

becomes:

jQuery(document).ready(function($){
    $('ui').sortable();
});

Upvotes: 2

Related Questions