English 中文(简体)
如何快速解锁事件 不论它附着在哪里?
原标题:How to quickly unbind an event wherever it s attached?
  • 时间:2012-05-23 19:57:11
  •  标签:
  • jquery

我安排了几次这样的活动:

$( #window-overlay ).on( click , overlayClickHandler);
$clickedObj.on( click , overlayClickHandler);

是否有一种简单的方法可以让我点击其中一种东西, 点击事件会被从另外一种东西中删除? 从 window-overlay 中删除它就足够简单了, 但$kickedObj 是 if 块内的一个变量, 所以以后可能很难弄清楚操作者被绑定的对象 。

问题回答

维护您想要为事件卸载的jquery 对象的数组, 并根据您的条件, 您可以通过数组, 并卸载所需的 jquery 对象... 您可以使用整齐的json 结构作为数组值来帮助您区分不同的捆绑事件 。 类似的东西 。

{
eventType: "click",
category: "myCategory1",
object: jqueryObject //or store the  selector if you want to keep a low memory footprint..
}

类别基本上用于分组相关事件,所以您只需解开必需的分类。

我不知道是否有更容易的替代办法,但这是一种办法,至少比找到所有受事件约束的控制措施要好





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签