Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JavaScript養成読本 特集1 第7章 リスト20 訂正
// 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());
return this;
events: {
'submit form': 'onSubmit'
onSubmit: function(e) {
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