Sir can u guide me in implementation of Ajax calls in Ruby and Rails? wen i m implementing a new page it gives th following op: "try { Element.hide("add_answer_link_for_post_-613772418"); Element.update("new_answer_form_for_post_-613772418", "<form action=\"/answers\" method=\"post\" onsubmit=\"new Ajax.Request(''/answers'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">\n<fieldset>\n <legend>New Answer</legend>\n <textarea cols=\"40\" id=\"answer_ans_string\" name=\"answer[ans_string]\" rows=\"10\"></textarea>\n <input name=\"commit\" type=\"submit\" value=\"Create\" />\n</fieldset>\n</form>\n\n"); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Element.hide(\"add_answer_link_for_post_-613772418\");\nElement.update(\"new_answer_form_for_post_-613772418\", \"<form action=\\\"/answers\\\" method=\\\"post\\\" onsubmit=\\\"new Ajax.Request(\''/answers\'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\\\">\\n<fieldset>\\n <legend>New Answer</legend>\\n <textarea cols=\\\"40\\\" id=\\\"answer_ans_string\\\" name=\\\"answer[ans_string]\\\" rows=\\\"10\\\"></textarea>\\n <input name=\\\"commit\\\" type=\\\"submit\\\" value=\\\"Create\\\" />\\n</fieldset>\\n</form>\\n\\n\");''); throw e }" I want to eliminate this problem wen i m implementing ajax requests.. Please help.. ALso m unable to understand the follwing code: <div id="comments_for_post_<%= post.id %>"> <%= render :partial => "comments/comment", :collection => post.comments %> </div> <% if logged_in? %> <div id="add_comment_link_for_post_<%= post.id %>"> <%= link_to_remote "Add a comment", :url => new_comment_path(post.blog, post), :method => :get %> </div> <div id="new_comment_form_for_post_<%= post.id %>"> </div> <% end %> </div> def new @comment = Comment.new respond_to do |format| format.js do render :update do |page| page.hide "add_comment_link_for_post_#{@post.id}" page.replace_html "new_comment_form_for_post_#{@post.id}", :partial => "new" end end end end please can anyone guide me wat does "add_comment_ink_for_post_#{@post.id}" do????? -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Manish Belsare> <% if logged_in? %> > <div id="add_comment_link_for_post_<%= post.id %>"> > <%= link_to_remote "Add a comment", > :url => new_comment_path(post.blog, post), > :method => :get %> > </div>> please can anyone guide me wat does > "add_comment_ink_for_post_#{@post.id}" do?????From your view code add_comment_ink_for_post_#{@post.id} is some div For example of @post.id=2 Then that div will be add_comment_ink_for_post_2> page.hide "add_comment_link_for_post_#{@post.id}"What this does is hide a div element As an example it hides the div add_comment_ink_for_post_2 Sijo -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sir, Can u please help me in the problem that is present at the top?? I dont know why ruby isnt supporting AJAX calls??? wat should i do 2 eliminate the problem...It is urgent...! Please help.. -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 17 February 2010 18:41, Manish Belsare <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Sir can u guide me in implementation of Ajax calls in Ruby and Rails? > wen i m implementing a new page it gives th following op: > > "try { > Element.hide("add_answer_link_for_post_-613772418"); > Element.update("new_answer_form_for_post_-613772418", "<form > action=\"/answers\" method=\"post\" onsubmit=\"new > Ajax.Request(''/answers'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this)}); return false;\">\n<fieldset>\n > <legend>New Answer</legend>\n <textarea cols=\"40\" > id=\"answer_ans_string\" name=\"answer[ans_string]\" > rows=\"10\"></textarea>\n <input name=\"commit\" type=\"submit\" > value=\"Create\" />\n</fieldset>\n</form>\n\n"); > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); > alert(''Element.hide(\"add_answer_link_for_post_-613772418\");\nElement.update(\"new_answer_form_for_post_-613772418\", > \"<form action=\\\"/answers\\\" method=\\\"post\\\" onsubmit=\\\"new > Ajax.Request(\''/answers\'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this)}); return false;\\\">\\n<fieldset>\\n > <legend>New Answer</legend>\\n <textarea cols=\\\"40\\\" > id=\\\"answer_ans_string\\\" name=\\\"answer[ans_string]\\\" > rows=\\\"10\\\"></textarea>\\n <input name=\\\"commit\\\" > type=\\\"submit\\\" value=\\\"Create\\\" > />\\n</fieldset>\\n</form>\\n\\n\");''); throw e }"You say that you get this when you have implemented a new page, but you have not shown the code of your page. It is therefore difficult for anyone to suggest what is wrong. 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
def new @answer = Answer.new respond_to do |format| format.js do render :update do |page| page.hide "add_answer_link_for_post_#{@post.id}" page.replace_html "new_answer_form_for_post_#{@post.id}", :partial => "new" end end end end _new.html.erb: <% remote_form_for(:answer, :url => answers_path) do |form| %> <fieldset> <legend>New Answer</legend> <%= form.text_area :body, :rows => 10, :cols => 40 %> <%= submit_tag "Create" %> </fieldset> <% end %> def create @answer = Answer.new(params[:answer]) @answer.user = User.find(session[:user_id]) @answer.post = @post respond_to do |format| if @answer.duplicate? or @post.answers << @answer format.js do render :update do |page| page.replace_html "answers_for_post_#{@post.id}", :partial => "answers/answer", :collection => @post.answers page.show "add_answer_link_for_post_#{@post.id}" page.hide "new_answer_form_for_post_#{@post.id}" end end else format.js { render :nothing => true } end end end _answer.html.erb <div id="answer_<%= answer.id %>" class="answer"> <hr noshade /> <% if logged_in? and answer.authorized?(User.find(session[:user_id])) %> <span class="edit_link" style="float: right"> <%= link_to_remote "(delete)", :url => answer_path(answer.post.blog, answer.post, answer), :method => :delete, :confirm => ''Are you sure?'' %> </span> <% end %> ABove is the code that uses Ajax but fails wen run..y? -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
def new @answer = Answer.new respond_to do |format| format.js do render :update do |page| page.hide "add_answer_link_for_post_#{@post.id}" page.replace_html "new_answer_form_for_post_#{@post.id}", :partial => "new" end end end end _new.html.erb: <% remote_form_for(:answer, :url => answers_path) do |form| %> <fieldset> <legend>New Answer</legend> <%= form.text_area :body, :rows => 10, :cols => 40 %> <%= submit_tag "Create" %> </fieldset> <% end %> def create @answer = Answer.new(params[:answer]) @answer.user = User.find(session[:user_id]) @answer.post = @post respond_to do |format| if @answer.duplicate? or @post.answers << @answer format.js do render :update do |page| page.replace_html "answers_for_post_#{@post.id}", :partial => "answers/answer", :collection => @post.answers page.show "add_answer_link_for_post_#{@post.id}" page.hide "new_answer_form_for_post_#{@post.id}" end end else format.js { render :nothing => true } end end end _answer.html.erb <div id="answer_<%= answer.id %>" class="answer"> <hr noshade /> <% if logged_in? and answer.authorized? (User.find(session[:user_id])) %> <span class="edit_link" style="float: right"> <%= link_to_remote "(delete)", :url => answer_path(answer.post.blog, answer.post, answer), :method => :delete, :confirm => ''Are you sure?'' %> </span> <% end %> ABove is the code that uses AJAX calls..but gives errors wen run..can any 1 help me in implementing AJAX in rails..i need it urgent -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Can you post the error message? -- Posted via http://www.ruby-forum.com/. -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.