I’m using jQuery Address to load in my content, but it’s doing it twice on the init. I set it up so that if you go to the main category it loads the first image, but it’s doing it twice and I’m not sure how to stop it. A fresh pair of eyes would be appreciated!
$.address.init(function(event) {
$('#carousel-clip a').address();
if(!event.pathNames[0]) {
var url = $('#carousel-clip ul li:first a').attr('href').replace('#!/','');
$.address.path(url);
}
}).change(function(event) {
if(event.pathNames[0]) {
$.getJSON(location.pathname + 'image/' + event.pathNames[0] + '/', function(data, textStatus, XMLHttpRequest) { handler(data); });
}
});
You can see it working here
The Problem is, that both $.address.path and the onHashChange-Event call the change-function directly. So $.address.path calls the change-function twice, since it changes the hash and therefore triggers an onHashChange-Event. You can circumvent this by replacing this:
with that:
This is a bit dirty but it should work.