I have my plugin. In that script executing multiple times.
$('element1').myplugin({callback:foo});
$('element2').myplugin({callback:bla});
second callback not working always calling ‘foo’.
plugin code:
(function($) {
$.fn.myplugin = function(options) {
//some code.
options.callback();
}
})(jQuery);
If I include one more element one more time script executing increasing.
am I doing anything wrong.
As many times you include your plugin then the code will also run there is nothing wrong. if you working with callbacks make sure that the callbacks are assigned inside the functions. so that you can avoid the conflict.