I am writing a jQuery plugin and associated with binding events to window.scroll. The action performed in window.scroll depends on the parameters passed during initial initialization.
How do I access a data item or to it inside a related event?
(function($) {
var methods = {
init : function(options) {
return this.each(function() {
$(window).bind("scroll.myPlugin", methods.windowOnScroll);
});
},
windowOnScroll : function() {
var $this = $(this);
var data = $this.data("scrollingLoader");
if (data.something) {
}
}
})(jQuery);
source
share