سؤال

I have a whole heap of checkboxes with an event handler 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.

If I toggle individual checkboxes, selectVid is called as expected.

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'); is always reached.

So why does trigger('change') no longer cause selectVid to be called after the facebox popup has been opened and closed?

هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top