Created
May 29, 2012 05:28
-
-
Save inossidabile/2822781 to your computer and use it in GitHub Desktop.
Joosy / Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Joosy.Form.attach $('element'), | |
success: (data) -> | |
error: (data) -> | |
progress: (data) -> | |
action: 'URL' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@afterLoad -> | |
@form = Joosy.Form.attach @rawForm, | |
resource: @data.post | |
success: (data) => @navigate '/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!= @render '_form' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
attr_accessible :body, :title | |
has_many :comments | |
validates :body, :presence => true | |
validates :title, :presence => true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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?
That was supposed to be a homework :)
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
thanks.