Sha256: e878c69950d9f25ae35a4f8eda77c411883a43aa88daede618065e8b44ca08b7

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

<%= user_view_namespace %> ||= {}

class <%= user_view_namespace %>.SignupView extends Backbone.View
  template: JST["<%= user_jst 'signup' %>"]

  events:
    "submit #new-user": "save"

  constructor: (options) ->
    super(options)
    @model = new <%= js_user_model_namespace %>Registration

    @model.bind("change:errors", () =>
      this.render()
    )

    @model.bind("error", (model, xhr, options) =>
      form_errors 'There was a problem signing up', xhr
    )

  save: (e) ->
    e.preventDefault()
    e.stopPropagation()

    @model.unset("errors")

    @model.save(@model.attributes,
      success: (user, response, options) =>
        @model = user
        window.<%= js_app_name %>.User = @model
        window.location.hash = "/"
    )

  render: ->
    @$el.html(@template(@model.toJSON() ))

    this.$("form").backboneLink(@model)

    return this

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pbw-0.0.10 lib/generators/pbw/templates/views/signup_view.coffee