Hi all, Question Give me some quick start to Ajax but should be simple because i have only theoretically knowledge of Ajax. Thanks Best Regards Fahim Babar Patel -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/U2zn9RMl3eAJ. For more options, visit https://groups.google.com/groups/opt_out.
I found this article on madebydna http://madebydna.com/all/code/2011/12/05/ajax-in-rails-3.html It really focuses on the rails ujs adapter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Fahim Patel ha scritto:> Hi all, > > Question > Give me some quick start to Ajax but should be simple because i have > only theoretically knowledge of Ajax.http://guides.rubyonrails.org/ajax_on_rails.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 7 November 2012 11:10, Tommaso Visconti <tommaso.visconti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Fahim Patel ha scritto: > >> Hi all, >> >> Question >> Give me some quick start to Ajax but should be simple because i have >> only theoretically knowledge of Ajax. > > > http://guides.rubyonrails.org/ajax_on_rails.htmlAm I going blind or is that not linked to from the index http://guides.rubyonrails.org/index.html ? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law ha scritto:> On 7 November 2012 11:10, Tommaso Visconti<tommaso.visconti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Fahim Patel ha scritto: >> >>> Hi all, >>> >>> Question >>> Give me some quick start to Ajax but should be simple because i have >>> only theoretically knowledge of Ajax. >> >> http://guides.rubyonrails.org/ajax_on_rails.html > > Am I going blind or is that not linked to from the index > http://guides.rubyonrails.org/index.html ?mmmm, yeah :) I found it with google -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 7 November 2012 12:16, Tommaso Visconti <tommaso.visconti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Colin Law ha scritto: > >> On 7 November 2012 11:10, Tommaso Visconti<tommaso.visconti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >>> >>> Fahim Patel ha scritto: >>> >>>> Hi all, >>>> >>>> Question >>>> Give me some quick start to Ajax but should be simple because i have >>>> only theoretically knowledge of Ajax. >>> >>> >>> http://guides.rubyonrails.org/ajax_on_rails.html >> >> >> Am I going blind or is that not linked to from the index >> http://guides.rubyonrails.org/index.html ? > > > mmmm, yeah :) > I found it with googleDoes anyone here do docrails (are the guides maintained by docrails)? It should be fixed. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thanks lot to all of you to reply . I follow below link which work perfectly for me. http://tekn0t.net/ajax-example-with-rails-3-and-jquery The link which i have given up is have full code. Below i have shown only confusing code to me. I firstly clear that i seen first time respond_to keyword and different type of formats . I know code is working perfectly when i do manual testing, but technically i am zero. Q1 I don'' t understood why there is create.js.erb and destroy.js.erb require? Q2 What is this format.js in controller ?Is this line call to create.js.erb ? Q3 below code confuse me . If record save than call goes to format.html which send us to index page than when call goes to format.js ? *Or it work line by line ?i am just guessing .* #################code#####################################################33 respond_to do |format| if @post.save format.html { redirect_to(posts_url, :notice => ''Post was successfully created.'') } format.js else format.html { redirect_to(posts_url) } end end end #######################code################################################## ########################PostsController###################### class PostsController < ApplicationController def index @posts = Post.all @post = Post.new respond_to do |format| format.html end end def create @post = Post.new(params[:post]) respond_to do |format| if @post.save format.html { redirect_to(posts_url, :notice => ''Post was successfully created.'') } format.js else format.html { redirect_to(posts_url) } end end end def destroy @post = Post.find(params[:id]) @post.destroy respond_to do |format| format.html { redirect_to(posts_url) } format.js end end end ################################################################################ ################create.js.erb############################################### $(''#posts'').prepend(''<%= escape_javascript(render(@post)) %>''); $(''#posts > li:first'').effect(''highlight'', {}, 3000); $(''#post_form > form'')[0].reset(); ################################################################################# ######################destroy.js.erb################################# $(''#<%= dom_id(@post) %>'').css(''background'', ''red''); $(''#<%= dom_id(@post) %>'').hide("fade", {}, 1500); ################################################################################## Waiting for reply. Thanks Best Regards Fahim Babar Patel On Wednesday, November 7, 2012 4:16:00 PM UTC+5:30, Tomiwa Ijaware wrote:> > I found this article on madebydna > http://madebydna.com/all/code/2011/12/05/ajax-in-rails-3.html > > It really focuses on the rails ujs adapter >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/wmwkJhvT6zUJ. For more options, visit https://groups.google.com/groups/opt_out.
On 8 November 2012 06:34, Fahim Patel <pafahim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks lot to all of you to reply . > > I follow below link which work perfectly for me. > http://tekn0t.net/ajax-example-with-rails-3-and-jquery > > The link which i have given up is have full code. Below i have shown only > confusing code to me. > > I firstly clear that i seen first time respond_to keyword and different type > of formats . > > I know code is working perfectly when i do manual testing, but technically i > am zero. > Q1 I don'' t understood why there is create.js.erb and destroy.js.erb > require? > Q2 What is this format.js in controller ?Is this line call to > create.js.erb ? > Q3 below code confuse me . > If record save than call goes to format.html which send us to index page > than when call goes to format.js ? > Or it work line by line ?i am just guessing .A good way to understand code that is unclear is to experiment with it and see what the effect is. If you don''t understand why files are there at all then remove them (or empty them) and see what stops working. If you don''t understand what a method call does then study the docs and google, and again experiment with changing it and see the effect. That way you will learn much more than simply having the answer given to you. Have you worked right through a tutorial such as railstutorial.org? I am sure I have already suggested that. Colin> #################code#####################################################33 > respond_to do |format| > > if @post.save > format.html { redirect_to(posts_url, > :notice => ''Post was successfully created.'') } > format.js > else > format.html { redirect_to(posts_url) } > end > end > end > > #######################code################################################## > > > ########################PostsController###################### > > class PostsController < ApplicationController > def index > @posts = Post.all > @post = Post.new > > respond_to do |format| > format.html > end > end > > def create > @post = Post.new(params[:post]) > > respond_to do |format| > if @post.save > format.html { redirect_to(posts_url, > :notice => ''Post was successfully created.'') } > format.js > else > format.html { redirect_to(posts_url) } > end > end > end > > def destroy > @post = Post.find(params[:id]) > @post.destroy > > respond_to do |format| > format.html { redirect_to(posts_url) } > format.js > end > end > end > ################################################################################ > > ################create.js.erb############################################### > $(''#posts'').prepend(''<%= escape_javascript(render(@post)) %>''); > $(''#posts > li:first'').effect(''highlight'', {}, 3000); > $(''#post_form > form'')[0].reset(); > > ################################################################################# > > ######################destroy.js.erb################################# > $(''#<%= dom_id(@post) %>'').css(''background'', ''red''); > $(''#<%= dom_id(@post) %>'').hide("fade", {}, 1500); > ################################################################################## > Waiting for reply. > Thanks > > Best Regards > Fahim Babar Patel > > > On Wednesday, November 7, 2012 4:16:00 PM UTC+5:30, Tomiwa Ijaware wrote: >> >> I found this article on madebydna >> http://madebydna.com/all/code/2011/12/05/ajax-in-rails-3.html >> >> It really focuses on the rails ujs adapter > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/wmwkJhvT6zUJ. > > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.