I just started playing with sammy.js, and the first thing I want to do is check how the history changes work. And it works as expected, even better, but as soon as I open IE10 and switch to IE9 browser mode, everything crashes. If I don't set up hash links, IE9 just keeps following the links. Same problem with IE8, of course.
At this point, I only have this bit of code related to sammy
App.sm = $.sammy('#content', function() { this.get('/', function(context) { console.log('Yo yo yo') }); this.get('/landing', function(context) { console.log('landing page') }); this.get('/:user', function(context) { console.log(context) }); });
And the initiator
$(function() { App.sm.run('/'); });
I also looked at this example , which contains three types of links, normal, hash and normal again, but it works correctly on IE9 and IE8. which makes me think that somehow it should be possible to make sammy.js support html5 history and html4 at the same time.
So my question will be, how can I achieve this?
Update
I found a way to make it work with IE
I just added this snippet:
this.bind('run', function(e) { var ctx = this; $('body').on('click', 'a', function(e) { e.preventDefault(); ctx.redirect($(e.target).attr('href')); return false; }); });
Anyway, I still have a problem logging into the site, html5, which supports browsers, is always redirected to the .com domain, regardless of what the starting URL was.
It is so interesting how should I configure sammy.js to work peroperly. Or maybe someone can recommend another router that will work well with knockout.js.