olivernn / davis.js

RESTful degradable JavaScript routing using pushState
http://davisjs.com
532 stars 58 forks source link

Routes doesn't trigger on page load #78

Closed odyssomay closed 11 years ago

odyssomay commented 11 years ago

I have this in a script on my page:

var app = Davis(function() {
  this.get("/", function(req) {
    console.log("/");
  });

  this.get(".*", function(req) {
    console.log("404");
  });
});

app.start()

Everything works fine when I click on a link, but not when reloading or writing the url manually. So am I doing something wrong or is this a problem with davis?

thasmo commented 11 years ago

That's a configuration option:

var router = Davis(function() {
    this.configure(function(settings) {
        settings.generateRequestOnPageLoad = true;
    });
});
odyssomay commented 11 years ago

Oh ok. Thanks! :)

geniuscarrier commented 10 years ago

Same issue, clicking on a link works fine. But reloading, it always says

"Not Found The requested URL /home was not found on this server."

Do I miss something? I am working with version 0.9.9.

    var app = Davis(function() {
        this.configure(function(settings) {
            settings.generateRequestOnPageLoad = true
        });
        this.get("/home", function (req) {
            console.log("test")
        });
    });
    app.start();
arthur24b6 commented 10 years ago

@geniuscarrier it sounds like you're trying to load a path that you server doesn't know about- I'm guessing the path /home is defined in your davis app, not on your server.