Sha256: 692424ea168784137be4f591c133d5744e2f6f35cc9cfe9a7f660636f59d505d

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

<%= view_namespace %> ||= {}

class <%= view_namespace %>.NewView extends Backbone.View
  template: JST["<%= jst 'new' %>"]
  
  events:
    "submit #new-<%= singular_name %>": "save"
    
  save: (e) ->
    e.preventDefault()
    e.stopPropagation()
      
    @options.collection.create(@options.model.toJSON(), 
      success: (model) =>
        @options.model = model
        window.location.hash = "/#{@options.model.id}"
    )
    
  render: ->
    @options.model = new @options.collection.model()
    $(this.el).html(this.template(@options.model.toJSON() ))
    
    this.$("form").backboneLink(@options.model)
    
    return this

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-backbone-0.1.2 lib/generators/backbone/scaffold/templates/views/new_view.coffee