jQuery 플러그인을 작성 중이며 이벤트를 window.scroll에 바인딩해야합니다. window.scroll 내에서 수행되는 동작은 원래 초기화가 호출 될 때 전달 된 설정에 따라 다릅니다.
바운드 이벤트 내에서 데이터 요소 또는 여기에 어떻게 액세스합니까?
(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);
나는이 답변을 좋아합니다! – xiaohan2012