开发者

jquery droppable target

开发者 https://www.devze.com 2023-01-08 07:58 出处:网络
If I have a table with a lot of cells, lets assume 50 rows x 50 columns, is the application of a jquery \"droppable\" to each cell inefficient?

If I have a table with a lot of cells, lets assume 50 rows x 50 columns, is the application of a jquery "droppable" to each cell inefficient?

Can I assign the droppable to the parent TABLE, for instance, and then somehow capture the actual element (ie. the TD) where the item is dropped? If I remember my event delegation correctly, in any given event the TD recieves it first, followed by t开发者_如何转开发he TABLE.

Can someone please enlighten me?

Jason


Yep you can do this using event delegation. Trying to listen for cliks on each TD tag would be a no no in terms of performance and would cause memory leak issues. Attach an event listener on the table tag and intercept the click event and determine which cell was clicked. Check this out, it talks using event delegation on a table to capture clicks on the TD elements:

http://www.sitepoint.com/blogs/2008/07/23/javascript-event-delegation-is-easier-than-you-think/

0

精彩评论

暂无评论...
验证码 换一张
取 消