Reputation: 1846
I read this one but since there was no answers and the question seems to irrelevant. I would like to ask it here again. I did exactly as the backbone documentation page instructs, but gained no results. Can someone help me point out what went wrong here? The code as following:
App.View.Task = Backbone.View.extend({
tagName: 'li',
template: _.template($("#taskTemplate").html()),
event: {
'click #edit': 'editTask'
},
editTask: function() {
alert("test");
},
render: function() {
this.$el.html(this.template(this.model.attributes));
return this;
}
})
the index.html page looks like this:
<script id="taskTemplate" type="text/template">
<button class="edit">edit</button> <button>delete</button>
</script>
Upvotes: 1
Views: 53
Reputation: 1846
Ignoring my typo when specify the element ID in the view, I found that the reason for Backbone not firing the event is because I load the script before that element.
Upvotes: 0