Browse - Programming Tips - How can I dynamically load a jquery.ui plugin?

Date: 2016nov28
Library: jQueryUI
Language: javaScript

Q.  How can I dynamically load a jquery.ui plugin?

A. Here's how

function dynamicallyLoadPlugin(plugin, id) { var func = $.fn[plugin]; func.call($('#' + id)); }
jQueryUI plugins live in $.fn.thePlugin so the first line of the function get a reference to it. Next we need to call that function. Normally its done like this: $('#id').plugin(). So we use standard javaScript call() which lets us specify the "this" variable.