setLocation bug with non-pushState

71 views
Skip to first unread message

Zachary Tong

unread,
Oct 7, 2012, 7:28:20 PM10/7/12
to sam...@googlegroups.com
Hi all,

I'm unsure if this is a bug, or simply a problem with my implementation.  But it certainly took me ages to hunt so I wanted to see what the group said.

I am setting this.app.disable_push_state = true, since I do not want pushState functionality at the moment.  However, I was running into a problem where the originally loaded hash would fail to load after several changes.  For example:

Originally loaded page: http://example.com/#!/search?q=123
Second page (via sammy redirect): http://example.com/#!/search?q=789
Third page (via sammy redirect): http://example.com/#!/search?q=123

The second redirect, back to the first page, does not trigger the route.  After extensive debugging, I isolated it to the setLocation function.  The function is fired but no redirect ever happens.

If I change the line
return (window.location = new_location);
to
return (window.location.hash = new_location);

then everything starts working beautifully.  So my question, is this a bug with Sammy, or is there something wrong with my implementation?  I certainly can't find anything wrong, but I also don't know much about redirecting hashes so perhaps something is incorrect?

Thanks,
-Zach


Ramiro

unread,
Oct 8, 2012, 3:33:43 AM10/8/12
to sam...@googlegroups.com
How are you doing the redirects?
Try: app.redirect('search', {q: 123})
Reply all
Reply to author
Forward
0 new messages