Sha256: f65cc35d738b59b7560d1f96697b286a7c650ad90c19ea30feb19a323e03890b
Contents?: true
Size: 780 Bytes
Versions: 4
Compression:
Stored size: 780 Bytes
Contents
Application.Views.Photos ||= {} class Application.Views.Photos.NewView extends Backbone.View template: JST["backbone/templates/photos/new"] events: "submit #new-photo": "save" constructor: (options) -> super(options) @model = new @collection.model() @model.bind("change:errors", () => this.render() ) save: (e) -> e.preventDefault() e.stopPropagation() @model.unset("errors") @collection.create(@model.toJSON(), success: (photo) => @model = photo window.location.hash = "/#{@model.id}" error: (photo, jqXHR) => @model.set({errors: $.parseJSON(jqXHR.responseText)}) ) render: -> @$el.html(@template(@model.toJSON() )) this.$("form").backboneLink(@model) return this
Version data entries
4 entries across 4 versions & 2 rubygems