Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created May 29, 2012 11:14
Show Gist options
  • Save inossidabile/2827878 to your computer and use it in GitHub Desktop.
Save inossidabile/2827878 to your computer and use it in GitHub Desktop.
Joosy / Dynamic Rendering
elements:
'titlePane': 'h1'
'titleForm': 'form'
events:
'click $titlePane': (element) ->
@titlePane.hide()
@titleForm.show()
@afterLoad ->
Joosy.Form.attach @titleForm,
resource: @data.post
success: =>
@data.post('title', @titleForm.find('input[type=text]').val())
@titleForm.hide()
@titlePane.show()
-# templates/pages/posts/show.jst.hamlc
%form{:style => 'display: none'}
%input{:type => 'text', :name => 'post[title]'}
%input{:type => 'submit'}
!= @renderDynamic '_title', @post
%hr
%p
= @post('body')
-# templates/pages/posts/show.jst.hamlc
!= @renderDynamic '_title', @post
%hr
%p
= @post('body')
-# templates/pages/posts/_title.jst.hamlc
%h1
%i.icon-book
= @title
%sup.badge.badge-success
24.05.2012
render 'foo', {foo: 'bar'}
# @foo = 'bar'
render 'foo', Post.build(title: 'test')
# @title = 'test'
Post.find 'all', (posts) -> render 'foo', posts
# @data = posts.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment