Search code examples
javascriptjquerycallbackjquery-addressswfaddress

jQuery Address do not work in callbacks


Today I explored something weird: jQuery Address do not work in jQuery callbacks: http://jsfiddle.net/Wh7uS/19/ Any suggestions?


Solution

  • Your binding to the init event of the address, which is triggered before the callback. You can see that if you change the fadein timer to 0:

    $("#second").fadeIn(0, function() {
    
    jQuery.address.init(function(event) {
        alert("jQuery Address - inside");
    });
    alert("Sorry for the many alerts");
    });
    

    It's callback will run immediately, binding the init event handler which will be invoked and shoot of the alert (all from in the callback). Timing is everything :)