I just started using the backbone.js framework using router
to generate urls in my html.
I have 3 buttons defined so
<ul class="list-inline ">
<li><button id="boton1" type="button" class="btn btn-primary" href="#vistade1">1</button></li>
<li><button id="boton2" type="button" class="btn btn-primary" href="#vistade2">2</button></li>
<li><button id="boton3" type="button" class="btn btn-primary" href="#vistade3">3</button></li>
</ul>
and my backbone code is this
(function(){
var Router = Backbone.Router.extend({
routes: {
"boton1/:id" : "vistauno",
"boton2/:id" : "vistados",
"boton3/:id" : "vistatres"
},
vistauno: function (boton1) {
console.log("estas intentando acceder a "+boton1);
},
vistados: function (boton2) {
console.log("estas intentando acceder a "+boton2);
},
vistatres: function (boton3) {
console.log("estas intentando acceder a "+boton3);
}
});
var Router = new Router();
Backbone.history.start();
});
It works for me when I put the path index.html#boton2
or index.html#boton3
by hand but if I give it by pressing the button it does not work.