JavaScript養成読本 特集1 第7章 リスト20 訂正
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
// js/note_form.js | |
App.NoteFormView = Backbone.View.extend({ | |
render: function() { | |
var template = $('#noteForm-template').html(); | |
var compiled = _.template(template); | |
var html = compiled(this.model.toJSON()); | |
this.$el.html(html); | |
return this; | |
}, | |
events: { | |
'submit form': 'onSubmit' | |
}, | |
onSubmit: function(e) { | |
e.preventDefault(); | |
var attrs = {}; | |
attrs.title = this.$('.js-noteTitle').val(); | |
attrs.body = this.$('.js-noteBody').val(); | |
this.trigger('submit:form', attrs); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment