简体   繁体   English

打开/关闭Facebox后jQuery触发器不起作用

[英]jQuery trigger not working after opening/closing facebox

I have a whole heap of checkboxes with an event handler selectVid . 我有一堆复选框和一个事件处理程序selectVid

$std_cbs.on('change', selectVid);

A "toggle all" checkbox toggles all other checkboxes, and triggers the "change" event for those checkboxes. “全部切换”复选框可切换所有其他复选框,并触发这些复选框的“更改”事件。

$checkboxes.prop('checked', is_checked).trigger('change');

This works great, until I open and close a facebox popup. 在我打开和关闭面板弹出窗口之前,这非常有效 After this when I toggle the "toggle all" checkbox the other checkboxes toggle as well, but their event handler selectVid is not called. 此后,当我切换“全部切换”复选框时,其他复选框也会切换,但不会调用其事件处理程序selectVid

If I toggle individual checkboxes, selectVid is called as expected. 如果我切换各个复选框, selectVid预期调用selectVid

If I refresh the page everything works again. 如果刷新页面,一切将再次起作用。 I've stepped through with Chrome's debugger, and the line $checkboxes.prop('checked', is_checked).trigger('change'); 我已经完成了Chrome调试器的调试,以及$checkboxes.prop('checked', is_checked).trigger('change'); is always reached. 总是达到的。

So why does trigger('change') no longer cause selectVid to be called after the facebox popup has been opened and closed? 那么,为什么在打开和关闭面框弹出窗口之后, trigger('change')不再导致selectVid被调用?

Thanks in advance! 提前致谢!

Ended up solving this by accident by using the Self-Executing Anonymous Functions pattern, as explained in this article . 最终通过使用“自执行匿名函数”模式来解决此问题,如本文所述

I assume there must have been a naming conflict when I opened facebox, which was resolved once I put all my functions and members in their own namespace (using the aforementioned pattern). 我假设打开Facebox时肯定存在命名冲突,一旦我将所有函数和成员放入自己的命名空间(使用上述模式)后,该问题便得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM