You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// A really lightweight plugin wrapper around the constructor,// preventing against multiple instantiations$.fn[pluginName]=function(options){returnthis.each(function(){if(!$.data(this,"plugin_"+pluginName)){$.data(this,"plugin_"+pluginName,newPlugin(this,options));}});};
I thought that this allowed to call the plugin multiple times on different objects, to keep the same functionality allowing to customize options for all elements the plugin is attached to.
However when in the plugin constructor I call a $( window ).resize( function() { // Code } ); and put some functions in it, it seems that the plugin doesn't work any more, especially if I use the functions in the extend functions. So I got rid of it and put everything in the main constructor. In this way the resize function works but custom options are overridden by the last elements, so all elements will behave like the last that has been called.
Why? Can you please help me better understand how to use this boilerplate?
I thought that this allowed to call the plugin multiple times on different objects, to keep the same functionality allowing to customize options for all elements the plugin is attached to.
However when in the plugin constructor I call a
$( window ).resize( function() { // Code } );
and put some functions in it, it seems that the plugin doesn't work any more, especially if I use the functions in the extend functions. So I got rid of it and put everything in the main constructor. In this way the resize function works but custom options are overridden by the last elements, so all elements will behave like the last that has been called.Why? Can you please help me better understand how to use this boilerplate?
here is my plugin test with its html page.
I am asking a similar question about the resize function and this boilerplate here, but that question still doesn't ask for multiple instantiations!
The text was updated successfully, but these errors were encountered: