मैं इस बात पर फंस गया हूं कि jQuery में नामित कस्टम ईवेंट कैसे काम करना चाहिए। मुझे the doc से इंप्रेशन मिला है जो एक नामित कस्टम इवेंट ट्रिगर करने से केवल उस घटना से जुड़ी हैंडलर को ही आग लग जाएगी। इसके बजाए, ऐसा लगता है कि नामस्थान बहुत अधिक अनदेखा है। नीचे दिए गए उदाहरण और यहाँ रहते कोड: http://jsfiddle.net/kZCBw/1/नामांकित कस्टम ईवेंट ट्रिगर
$(document)
.bind("reset.one", function(){ console.log("reset.one event detected");})
.bind("reset.two", function(){ console.log("reset.two event detected");})
.bind("cheese", function(){ console.log("cheese event detected");});
$("#btn1").click(function(){
console.log("firing reset.one event");
$(this).trigger("reset.one");
});
$("#btn2").click(function(){
console.log("firing reset.two event");
$(this).trigger("reset.two");
});
$("#btn3").click(function(){
console.log("firing reset event");
$(this).trigger("reset");
});
//btn1 click should only trigger handlers bound to "reset.one"
//and yet it triggers anything starting w/ "reset"
मैं क्या याद आ रही है?
अग्रिम धन्यवाद! -matt
साइड नोट: एक अच्छा जवाब के लिए jQuery 2.1.4 और jQuery 3.0 – ViRuSTriNiTy