How to change Hash without triggering Sammy route event ?

276 views
Skip to first unread message

Helder Oliveira

unread,
May 1, 2013, 10:00:14 PM5/1/13
to sam...@googlegroups.com
Hi,

I'd like to know if it's possible to change the Hash without triggering Sammy defined route ?


Someone else also posted this http://stackoverflow.com/questions/14158134/change-hash-without-triggering-sammy-event

Thanks for looking : D

Kake

unread,
Jun 18, 2013, 8:40:58 AM6/18/13
to sam...@googlegroups.com
Also looking for a solution for this..The Stackoverflow answer did not work for me.

Helder Oliveira

unread,
Jun 18, 2013, 11:51:49 AM6/18/13
to sam...@googlegroups.com
Hey,

Use a variable to lock going any further when setting the hash manually!

For example,

// change hash if needed
api[ 'setHash' ] = function(hash) {

api[ 'setHashLocker' ] = true; 

if (hash !== window.location.hash) {
window.location.hash = hash;
};

setTimeout(function(){
api[ 'setHashLocker' ] = false;
}, 400);

};


var app = $.sammy('#foo', function() {

this.get('#!/home', function() {

if(api[ 'setHashLocker' ] === true){
return;
};

/* your usual code goes here */

};

};
Reply all
Reply to author
Forward
0 new messages