When a plugin instance is created, it is stored on the original DOM element using jQuery.data, with the plugin's full name (the plugin's namespace, plus a hyphen, plus the plugin's name) as the key.
var bar = $( "<div />")
.appendTo( "body" )
.progressbar()
.data( "nmk-progressbar" );
// Call a method directly on the plugin instance.
bar.option( "value", 50 );
// Access properties on the plugin instance.
alert( bar.options.value );
I think the example given is misleading even with the namespace specified in accessing jQuery.data,
i.e. .data("nmk-progressbar").
The issue is that .progressbar() actually creates an instance of the Progressbar Widget of jQuery UI https://api.jqueryui.com/progressbar/#quick-nav rather than one of the plugin nmk-progressbar
built with Widget Factory.
The code snippet happens to make it being able to access the plugin instance of nmk-progressbar
by using the key "nmk-progressbar", which does run successfully but incorrect in meaning.
As considering the context in the article is with jQuery UI Widget Factory, this suggests audiences
that it is a way, using .progressbar(), to make an instance of the plugin nmk-progressbar.
I hope I am not wrong and expect for comments from anyone experienced.
Thanks ^_^
https://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/#the-widget-factory-under-the-hood
When a plugin instance is created, it is stored on the original DOM element using
jQuery.data
, with the plugin's full name (the plugin's namespace, plus a hyphen, plus the plugin's name) as the key.I think the example given is misleading even with the namespace specified in accessing jQuery.data, i.e.
.data("nmk-progressbar")
.The issue is that
.progressbar()
actually creates an instance of the Progressbar Widget of jQuery UI https://api.jqueryui.com/progressbar/#quick-nav rather than one of the plugin nmk-progressbar built with Widget Factory.The code snippet happens to make it being able to access the plugin instance of nmk-progressbar by using the key "nmk-progressbar", which does run successfully but incorrect in meaning.
As considering the context in the article is with jQuery UI Widget Factory, this suggests audiences that it is a way, using .progressbar(), to make an instance of the plugin nmk-progressbar.
I hope I am not wrong and expect for comments from anyone experienced. Thanks ^_^