0
jQuery에 대해 clickOut
이벤트를 작성했습니다. 그것은 아주 기본적인 것들을 위해 작동합니다. 이제 드롭 다운 메뉴로 테스트를 확대하고 있습니다. 마치 this
이 클로저에 매달려있는 것 같습니다. 어떻게하면 clickOut
이 호출되는 방식을 변경하지 않고이 문제를 해결할 수 있습니까?jQuery의 clickOut 이벤트
this
바인딩되지 않습니다
(function ($) {
'use strict';
$.fn.clickOut = function (eventData, handler) {
$('html').click($.proxy(function (event) {
if (this.has(event.target).length === 0) {
event.delegateTarget = this.get();
console.log(this);
if (handler === undefined) {
eventData(event);
} else {
handler(event);
}
}
}, this));
};
}(jQuery));
jQuery('li').click(function (event) {
jQuery(this).children().toggle('fast');
console.log(this);
event.stopPropagation();
});
jQuery('li li').clickOut(function() {
console.log(this);
jQuery(this).children().hide('fast');
});
+1 해결책이 될 것으로 보인다. – VisioN
완벽. 이제 거의 끝났어. 고마워. –