Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

how to catch 404s with can.route.pushstate

$
0
0
This works fine for <a href="/app/broken-link/">asdf</a> but not for <a href="/app/deep/broken/link">asdf</a>. I'd rather not add infinite amounts of can.route(":section/:sub/")
  1. can.route.bindings.pushstate.root = "/app/";

  2. can.route("", {section:""});
  3. can.route(":section/");
  4. can.route.ready();

  5. "{can.route} section": function(route, event, newVal)
  6. {
  7.     switch (newVal)
  8.     {
  9.         case "":
  10.         {
  11.             console.log("home");
  12.             break;
  13.         }
  14.         case "some-page1":
  15.         case "some-page2":
  16.         {
  17.             console.log(newVal);
  18.             break;
  19.         }
  20.         default:
  21.         {
  22.             console.log("404");
  23.         }
  24.     }
  25. }

Viewing all articles
Browse latest Browse all 3491

Trending Articles