Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created May 29, 2012 05:28
Show Gist options
  • Save inossidabile/2822781 to your computer and use it in GitHub Desktop.
Save inossidabile/2822781 to your computer and use it in GitHub Desktop.
Joosy / Forms
Joosy.Form.attach $('element'),
success: (data) ->
error: (data) ->
progress: (data) ->
action: 'URL'
@afterLoad ->
@form = Joosy.Form.attach @rawForm,
resource: @data.post
success: (data) => @navigate '/'
# posts/new
elements:
'rawForm': 'form'
@fetch (complete) ->
@data.post = Post.build()
complete()
# posts/edit
elements:
'rawForm': 'form'
@fetch (complete) ->
Post.find @params.id, (post) =>
@data.post = post
complete()
%form.well
%input.span10{:name => 'post[title]', :placeholder => 'Title'}
%textarea.span10{:name => 'post[body]', :placeholder => 'Body'}
%input.btn.btn-success.span4{:type => 'submit', :value => 'Save'}
rails g joosy:page blog/posts/edit
# exist blog/pages/posts
# create blog/pages/posts/edit.js.coffee
# exist blog/templates/pages/posts
# create blog/templates/pages/posts/edit.jst.hamlc
rails g joosy:page blog/posts/new
# exist blog/pages/posts
# create blog/pages/posts/new.js.coffee
# exist blog/templates/pages/posts
# create blog/templates/pages/posts/new.jst.hamlc
!= @render '_form'
class Post < ActiveRecord::Base
attr_accessible :body, :title
has_many :comments
validates :body, :presence => true
validates :title, :presence => true
end
Joosy.Router.map
404 : (path) -> alert "Page '#{path}' was not found :("
'/' : -> @navigate '/posts'
'/posts' :
'/' : Posts.IndexPage
'/new' : Posts.NewPage
'/:id/edit' : Posts.EditPage
'/:id' : Posts.ShowPage
@regmiprem
Copy link

this part is confusing part.
can u give me the all source code of this joosy blog.
waitin ur reply

@inossidabile
Copy link
Author

They are available from the start at https://github.com/roundlake/joosy-example. Please use stack overflow for your questions :)

@regmiprem
Copy link

thanks !! can u give me the idea about using javascript in rails like drag n drop, file uploader. i need help.

@regmiprem
Copy link

Comment part is not working rest of all works fine!!

@inossidabile
Copy link
Author

@regmiperm, please use stack overflow with joosy tag to ask your questions. Also, not sure what the "comment part" is.

@regmiprem
Copy link

thanks.

@regmiprem
Copy link

I mean in blog there is no comment part but it is described in first to make comment model so I want to know where comment part is used in joosy blog?

@inossidabile
Copy link
Author

That was supposed to be a homework :)

@regmiprem
Copy link

oh thanks for responsing me .. thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment