Initializing a jQuery UI Plugin with Custom Options - J Query

You want to use a jQuery UI plugin but with options other than those selected by the plugin author to be the built-in defaults.


Specify default option overrides in an options hash as the first argument to the plugin init method call:

Any option values you specify on init will override the default value. All unspecified options values will maintain the default.
The options hash, whether all defaults or some defaults plus some custom options, is the basis for the initial state of the plugin. That state is specific to the combination of that DOM Element with that jQuery UI plugin. For example, you might initialize a single element with two different jQuery UI plugins that each has a color option:

Now, #myDiv, what’s your foo color? Black. What’s your bar color? Green. Both are separate from the CSS color. In some later recipes, we’ll get into how to ask elements what their plugin values are, as well as how to give them new values.
Also important to note is now that #myDiv is initialized as a foo and a bar, it is no longer affected by those plugin defaults. The defaults are only used on init as a template for the plugin’s initial state.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

J Query Topics