我有问题要取消绑定一个听众,听共享发射器之一:jQuery的解除绑定监听
// this is emitter. Fire always in a.b.c namespace but with different parameters
$(document).trigger("a.b.c", {
p: 1,
p2: ...
});
// listener 1
$(document).bind("a.b.c", function(e, object) {
if (object.myParam) {
....
}
});
// listener 2
$(document).bind("a.b.c", function(e, object) {
if (object.anotherParam) {
....
}
});
如何解除绑定监听器2,所以听众1还是继续工作?
你怎么去那种情况下调用。你的设计必须有设计缺陷 –
你能解释为什么它有缺陷吗?我需要相同的命名空间,但具有不同的数据。 –