edubkendo
8/22/2012 - 11:16 AM

Form and show for tower.js. Should be able to get the generators creating these quickly enough.

Form and show for tower.js. Should be able to get the generators creating these quickly enough.

How to make missing views and forms in tower.js.

# app/views/users/_form.coffee

text '{{#with resource}}'
div class: 'control-group', ->
  div class: 'controls', ->
    p "Email: "
    text '{{view Ember.TextField valueBinding="email"}}'
    text '{{#with errors}}'
    span class: 'help-inline error', '{{email}}'
    text '{{/with}}'
div class: 'control-group', ->
  div class: 'controls', ->
    p "First name: "
    text '{{view Ember.TextField valueBinding="firstName"}}'
    text '{{#with errors}}'
    span class: 'help-inline error', '{{firstName}}'
    text '{{/with}}'
div class: 'control-group', ->
  div class: 'controls', ->
    p "Last name: "
    text '{{view Ember.TextField valueBinding="lastName"}}'
    text '{{#with errors}}'
    span class: 'help-inline error', '{{lastName}}'                  
    text '{{/with}}'
    a '{{action submit target="resource"}}', 'Submit User'
text '{{/with}}'

And here's a simple show page:

# app/views/users/_form.coffee

text '{{#with resource}}'
dl class: "content", ->
  dt "Email:"
  dd '{{email}}'
  dt "First name:"
  dd '{{firstName}}'
  dt "Last name:"
  dd '{{lastName}}'
text '{{/with}}'

Took me a good bit to figure out that submit action, but I should have gotten it much much more quickly. Just wasn't thinking.