This is a simple interface for creating jQuery plugin.
$.plugin( object );
object.name
: Plugin nameobject.parent
: Superclass plugin (optional)object.defaults
: Default options objectobject.methods
: Instance methods object
You can easily define a jQuery plugin with this interface.
$.plugin({
name: 'myPlugin',
defaults: {
foo: 'bar'
},
methods: {
initialize: function () {
// Constructor
},
myMethod: function (param1, param2) {
// Plugin instance method
}
}
});
$('#myElement').myPlugin();
// Call plugin method at any time.
$('#myElement').myPlugin('myMethod', ['Hello', 'World']);