Closed lgomez closed 13 years ago
Yes. You can override notFound(): http://code.quirkey.com/sammy/docs/api.html#Sammy.Application-notFound https://github.com/quirkey/sammy/blob/master/lib/sammy.js#L1141
That worked perfectly.
Did you consider adding a something like '404' as a route instead of requiring an override? Not a big deal. Just curious.
Thanks!
Hey, I'm looking for the same thing myself - had a look through the docs, but still not sure where I need to override notFound().
If you have time, could you please explain how and where to override it? Thanks!!
Sure, in my case I did something similar to:
var app = $.sammy('#somediv', function() {
this.get('#/somehash', function(context) {
// do somethihnng
});
this.notFound = function(){
// do something
}
});
I hope that helps.
Thanks! Yeah that clears it up. This worked great for me as an example:
this.notFound = function(){
this.swap('');
$("<p>Oops, that couldn't be found</p>").appendTo(this.$element());
}
Wonder how this impacts SEO - whether these 404s are treated like normal HTML 404s :S
@josscrowcroft So far I've only used sammy for apps behind a login to avoid dealing with SEO and other issues like that. There are ways to work around them but I prefer to avoid them and keep it simple.
Fair play. Cheers!
I use notFound to trigger a jQuery UI modal, or an internal message. Handy, thx. :-)
Is there a way for me to set a 404 route or a catch-al route for when none of my defined routes match?