jQuery Plugin - Public method - Data only targeting one element
I'm trying to write a plugin that will select multiple elements and then
apply some private methods to them (see code below). Then I also want to
give the user the ability to trigger the activation of the plugin's
methods manually with a .activate() function.
Here is my code :
MARKUP :
https://github.com/simonwalsh/jquery.imagepox/blob/master/demo/index.html
JS :
https://github.com/simonwalsh/jquery.imagepox/blob/master/dist/jquery.imagepox.js
Basically, when I select multiple items and then try to use the manual
activation like so :
$(".pox-wrapper").imagepox({ // NOTE: selects two elements
manualActivation: true
});
var manual = $(".pox-wrapper").data('imagepox');
setTimeout(function(){
manual.activate();
}, 5000);
It will only apply the activate() method to the first element in the query...
This is my first jQuery plugin and I've been able to handle everything so
far but I'm not sure about this one or even if it is the right way to
effectively call a public method. I also tried using a custom event with
an event listener in the plugin but it still only applies the methods on
the first element in the page.
Thanks in advance :)
No comments:
Post a Comment