Created
October 22, 2014 03:06
-
-
Save ykhs/f2ab66e8a67be16781d3 to your computer and use it in GitHub Desktop.
JavaScript養成読本 特集1 第7章 リスト1 訂正
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.NoteListItemView = Backbone.View.extend({ | |
tagName: 'tr', | |
initialize: function() { | |
// モデルのdestroyイベントを監視して | |
// Backbone.Viewのremove()メソッドを呼び出す | |
this.listenTo(this.model, 'destroy', this.remove); | |
}, | |
// [Delete]ボタンを監視して | |
// onClickDelete()メソッドを呼び出す | |
events: { | |
'click .js-delete': 'onClickDelete' | |
}, | |
render: function() { | |
var template = $('#noteListItemView-template').html(); | |
var compiled = _.template(template); | |
var html = compiled(this.model.toJSON()); | |
this.$el.html(html); | |
return this; | |
}, | |
onClickDelete: function() { | |
// モデルを削除する | |
this.model.destroy(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment