WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When closing the Thickbox (by clicking on the cross), I am invoking the following function, by hooking it to the tb_unload action. However, the action is being called twice for some reason, and I don't know why. Is there a way to stop the functino running more than once? Or better yet, finding out what is causing the action to be called twice? Thanks.


    $(window).bind('tb_unload', function(){

        /** Set the params for passing to the AJAX function */
        data = {
            security: $('input#_wpnonce', '#dd-options-edit-footer-page').val(),
            action: 'update-footer-images',

        $.post('admin-ajax.php', data, function(response){


            /** Place the image src in the hidden image, and then show the image */
            $('#image-preview', '#dd-optinos-footer-page').html(response);



share|improve this question
Have you used any development tools to debug the JavaScript? (Firebug, Chrome Developer Tools, etc)? – Jared Cobb Jan 3 '13 at 19:24
Yes, I use Firebug, but I'm unaware that you are able to use it for this. How would I go about finding this out in Firebug? – David Gard Jan 4 '13 at 9:10
One of Firebug's more powerful features is the Script panel. If you enable that panel you'll have access to all of the JavaScript being used on that page. But the real power comes from setting breakpoints and "debugging" your scripts while they run. This simply means being able to tell the browser to "pause" in the middle of running the code and allow you to "step" along and "watch" variable values. This tutorial is well worth the effort and once you learn to use the debugger you'll save yourself a lot of frustration and time. netmagazine.com/tutorials/javascript-debugging-beginners – Jared Cobb Jan 4 '13 at 13:43
Thanks very much for the link, I will review as soon as I get the chance. – David Gard Jan 4 '13 at 15:38
up vote 1 down vote accepted

A very basic fix would be to use one() instead of bind(). But why the function is called twice is still open. Ask your browser’s JavaScript inspector.

share|improve this answer
Thanks, .one() is working. I do use Firebug, but I'm not familier with using it for this reason, so am strugging a little bit... – David Gard Jan 4 '13 at 13:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.