I cannot get sammy.js to work as expected.
I have the following javascript.
(function ($) {
var app = $.sammy('#main', function () {
this.get('#/', function (context) {
context.log("start page");
});
this.get("#/another/:id/", function (context) {
context.log("another page with id = " + context.params["id"]);
});
});
$(function (context) {
app.run('#/');
});
})(jQuery);
I understand that whenever the URL has changed, and while the new route matches one of the declared routes, I should see the corresponding message in the console log.
But I do not.
When the first page loads, I see the message "start page". So far so good.
If i then
- click the link that points to [my url] / # / another / 1 /
- manually enter [my url] / # / other / 1 / into the address bar and press <Enter>
... nothing happens, i.e. I do not see the message for the second route.
However, with the second route in the address bar, if I delete F5 now or click the refresh button of the browser, the page will reload and display the expected console message.
, , URL-, ? - , script?