Binding the 'cbox_complete' event to document inside an AJAXed Colorbox

Oct 30, 2010 22:10

Just a quick note about using Colorbox, may be useful to someone.

If you have Javascript inside the HTML for a modal you're loading with an AJAX colorbox, and you bind to document's cbox_complete inside the modal's HTML, you might have to make sure to unbind it again when the modal closes.

Otherwise, if you have anything like a form submit bind inside your modal's JS on that event (cbox_complete) then it will bind twice the second time you open the modal, thrice on the third open, and so on.

So what you can do is put this in your main.js file inside a $(document).ready(function() { ... });

$(document).bind('cbox_cleanup', function(){
        $(document).unbind('cbox_complete');
    });

double submit, colorbox, jquery

Previous post Next post
Up