Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript養成読本 特集1 第7章 リスト1 訂正
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());
return this;
onClickDelete: function() {
// モデルを削除する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment