quirkey / sammy

Sammy is a tiny javascript framework built on top of jQuery, It's RESTful Evented Javascript.
http://sammyjs.org
MIT License
2.99k stars 384 forks source link

Sammy needs basepath in a route in order to get it working #255

Open ghost opened 7 years ago

ghost commented 7 years ago

The base url for my site is http://localhost:23773/mvn I feed it a route like this, as per the instructions on sammyjs.org:

var app = $.sammy(function () {
                this.get('#/advantages', function (context) {
                    console.log('advantages'); 
                });
            });

$(function () {
    app.run('#/advantages');
});

Then, I request http://localhost:23773/mvn/#advantages. Instead of running the "#/advantages" route I fed it, it gives me this error:

body 404 Not Found get /mvn/#advantages Error: 404 Not Found get /mvn/#advantages (…)

I'm surprised. Why is the '/mvn' included in the route? If I understand correctly, it shouldn't be there at all.

pushkeryadav commented 7 years ago

@rensdenobel This is because you are running wrong hash route.

You are defining "#/advantages" this route but while running the app you are using "/#advantages". got the difference, place of "/".

use "#/advantages" , it will start working.

ghost commented 7 years ago

Thanks @pushkeryadav ! Working late is not something we should do regularly ;)