Sha256: f525baf3e3cac08add764b59bfb9565b4ff629e907bae4c516b9c02d6a391e7d
Contents?: true
Size: 918 Bytes
Versions: 5
Compression:
Stored size: 918 Bytes
Contents
<%= view_namespace %> ||= {} class <%= view_namespace %>.NewView extends Backbone.View template: JST["<%= jst 'new' %>"] events: "submit #new-<%= singular_name %>": "save" constructor: (options) -> super(options) @options.model = new @options.collection.model() @options.model.bind("change:errors", () => this.render() ) save: (e) -> e.preventDefault() e.stopPropagation() @options.model.unset("errors") @options.collection.create(@options.model.toJSON(), success: (model) => @options.model = model window.location.hash = "/#{@options.model.id}" error: (model, jqXHR) => @options.model.set({errors: $.parseJSON(jqXHR.responseText)}) ) render: -> $(this.el).html(this.template(@options.model.toJSON() )) this.$("form").backboneLink(@options.model) return this
Version data entries
5 entries across 5 versions & 1 rubygems