jQuery plugin
can/control/pluginThe can.Control.plugin
extension is a plugin for creating and accessing
controls with jQuery helper methods. It uses the control's fullName
or a static pluginName attribute for the name of the control.
The can.Control.plugin
extension is a plugin for creating and accessing
controls with jQuery helper methods. It uses the control's fullName
or a static pluginName attribute for the name of the control.
For example, the following plugin:
Can now be created directly on the jQuery collection like:
Note: This plugin only supports jQuery.
Invoking Methods
You can invoke methods on a control instance after its created through a few different approaches.
Once a controller is initialized on a DOM element, you can invoke a method by calling the plugin with the method name followed by the parameters for that method. When calling a method and it returns a value other than
undefined
, this value will be returned. Otherwise the method call will return the jQuery object (for chaining).You can also retrieve the control instance and invoke the method directly.
For more information on this, see jQuery.fn.control or jQuery.fn.controls.
Demo
The following demo shows creating a plugin widget and then updating the widget's
times
variable for each time the button was clicked.