Comment utiliser les routeurs Pushstate dans Backbone.JS
-
11-11-2019 - |
Question
J'utilise un routeur ci-dessous
App.Router.PersonRouter = Backbone.Router.extend({
routes: {
"": "homepage",
"/p/:id": "getpost",
"/p/:id/*file": "download"
},
homepage: function () {
alert("requesting home page");
},
getpost: function (id) {
alert("Requested post with id " + id);
},
download: function (id, file) {
alert("person with id " + id + " is requesting file " + file);
}
});
et a commencé à essayer HTML5 pushState
Option dans Backbone.js. En faisant ci-dessous, car les fichiers sont servis à partir du fichier index.html. C'est juste ça alerts
N'affichez pas lorsque vous utilisez l'API HTML5 Pushstate, mais le fait joyeusement lors de l'utilisation d'URL de hashbang.
Backbone.history.start({pushState:true,root:"index.html"});
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow