jQuery Address do not work in callbacks

197 Views Asked by At

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

3

There are 3 best solutions below

0
Lior On BEST ANSWER

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

0
Needhi Agrawal On

change jquery to jquery <1.6 and things work fine.

1
Andrea Turri On

Are you looking for something like that? http://jsfiddle.net/Wh7uS/18/