Permalink
Browse files

added more helpers

  • Loading branch information...
1 parent 3023293 commit fb413323ffa9e6ccda989b6f8388ddbfc06386dd @dnagir committed Oct 22, 2011
Showing with 25 additions and 0 deletions.
  1. +23 −0 README.md
  2. +2 −0 app/assets/javascripts/spine-extensions.coffee
View
@@ -13,6 +13,29 @@ Currently it includes:
- `@view 'show'` = `JST['app/views/posts/show']`
- `@generate 'show', post` = `JST['app/views/posts/show'](post)`
+- `@htmlify 'show', post` = `@html JST['app/views/posts/show'](post)`
+
+Examples:
+
+```coffee
+class App.Users extends Spine.Controller
+ elements:
+ 'form': 'form',
+ # You would need elements for the inputs without the helpers:
+ 'input[name='email']: 'email_input',
+ 'input[name='name']: 'name_input'
+
+ render: -> @htmlify 'edit', @model
+
+ renderWithNoHelpers: ->
+ @html JST['app/views/posts/show'](@model)
+
+ updateModelFromForm: ->
+ @model.updateAttributes @form.serializeForm()
+
+ updateModeFromFormWithNoHelpers: ->
+ @model.updateAttributes { email: email_input.val(), name: name_input.val() }
+```
### jQuery Extensions:
@@ -17,4 +17,6 @@ Spine.Controller.include
generate: (name, data) -> @view(name)(data)
+ htmlify: (name, data) -> @html @generate(name, data)
+

0 comments on commit fb41332

Please sign in to comment.