I'm trying to make a simple view to test with backbone. I've started with events, but no one fires. Why ? I've made already other things with backbone like routing etc. without problems. Thanks for your time. My backbone definitions are from -> this source <-
module Views {
export class MenuView extends Backbone.View {
constructor(viewOptions?: Backbone.ViewOptions) {
super(viewOptions);
}
el = document.body;
events = {
"click #Btn-Start": "navigate",
"click #Btn-Software": "navigate",
"click #Btn-Anderes": "navigate",
"click #Btn-Impressum": "navigate"
};
initialize() {
console.log("initialize"); // fire
}
render() {
console.log("render"); // not fire
}
navigate() {
console.log("navigate"); // not fire
}
}
}
<body>
<div id="Menu">
<div id="Btn-Start"></div>
<div id="Btn-Software"></div>
<div id="Btn-Anderes"></div>
<div id="Btn-Impressum"></div>
</div>
<body>
EDIT: Tried routes with the route(name: string, callback: function) and the routes as object. It seems to work with a function reference but not as string in the routes object. Maybe there is a way to declare it in the view like these.
MenuView
? Because you should do it when the DOM is loaded... – nemesvel = "body"
. And also the typescirptMenuView extends Backbone.View
is not exactly the same with the Backbone way:var MenuView = Backbone.View.extend({
... – nemesv