jQuery hashchange trick

When using jquery haschange plugin. You have a button and when you click it you change the hash. But sometimes it's behavior is wrong. If you have ajax operations if not send it's a problem. The solution is first you set fake hash.

$('.your_selector').click(function(){
	hash('your-hash-value');
});

function hash(hashValue) {			
	location.hash = 'example';
	location.hash = hashValue;
}

$(window).hashchange( function(){
	//ajax operations
});

Posted in "jQuery" Views 5148            Published 02/03/2018

All Comments (0)
No Comments