微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Intercept

程序名称:Intercept

授权协议: 未知

操作系统: 未知

开发语言:

Intercept 介绍

This plugin simplifies the use of Event
Delegation
with multiple different descendants.

This concept is very useful for pages with dynamic content (f.e: AHAH) where
DOM elements are created and removed constantly, requiring re-binding.
This method also saves a lot of resources, as it uses less event handlers to
achieve the same objective.

It can be used in 2 ways:(I will exemplify with a table)

$('table') .intercept('click', 'tr', function(e){...}) .intercept('click', 'td.happy', function(e){...}) .intercept('click', '#something', function(e){...});

or

$('table').intercept('click', { tr: function(e){...}, 'td.happy': function(e){...}, '#something': function(e){...} });

By calling intercept on the same element/event, the new handler/s are appended
to the old list.

jQuery.Intercept won’t have such a good perfomance when many different
selectors are registered to one element, this can be noted for events that are
triggered very often, like mouSEOver. If you need more scalability, and you
can handle your problem with simpler selectors. Then you should check
jQuery.Listen instead, for a
similar approach.

Since 1.1.2, “absolute” selectors are supported, that is, selectors that
specify parents, descendants, siblings. Just use it the way it’s normally
used.
Thanks to Michael Grosser for bringing up the idea.

Intercept 官网

http://plugins.jquery.com/project/Intercept

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐