Hi I have a strange problem, I am using the below code form_remote_tag :url => ''/abc/test'',:before => "return hello();", :update=>''test_categories'' ,:complete => "Element.hide(''spinner'')", :loading => "Element.show(''spinner'')" do I am using :before=> function to validate the fields in the form, but the problem is that it does not update the div test_categories, instead opens as a separate page like regular form. If I remove this :before=> all works fine. the function hello is below and just a normal js function hello() { if(document.getElementById("card_no").value=="") { alert("Card not captured, please try again") document.getElementById("card_no").focus() return false; } return true; } Any Ideas? -- 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, Did you remember to include the relevant JavaScript files e.g <%= javascript_include_tag :defaults %> On 5 May, 13:04, shaan ss <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi I have a strange problem, I am using the below code > > form_remote_tag :url => ''/abc/test'',:before => "return hello();", > :update=>''test_categories'' ,:complete => "Element.hide(''spinner'')", > :loading => "Element.show(''spinner'')" do > > I am using :before=> function to validate the fields in the form, but > the problem is that it does not update the div test_categories, instead > opens as a separate page like regular form. If I remove this :before=> > all works fine. > > the function hello is below and just a normal js > function hello() > { > > if(document.getElementById("card_no").value=="") > { > alert("Card not captured, please try again") > document.getElementById("card_no").focus() > return false; > } > return true; > } > > Any Ideas? > -- > Posted viahttp://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@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.
Floyd Joseph wrote:> Hi, > > Did you remember to include the relevant JavaScript files e.g > <%= javascript_include_tag :defaults %>Yes thats included, else form_remote_tag would not have worked upon removing :before=> It works fine if i dont include the :before=> function , if I include it doesn work -- 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.
Is it because you''ve got return then the function name? What does that function itself return? Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 06/05/2010, at 2:33 AM, shaan ss <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Floyd Joseph wrote: >> Hi, >> >> Did you remember to include the relevant JavaScript files e.g >> <%= javascript_include_tag :defaults %> > > > Yes thats included, else form_remote_tag would not have worked upon > removing :before=> > > It works fine if i dont include the :before=> function , if I include it > doesn work > -- > 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. >-- 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.
The other thing i''d suggest is to look up the API for form remote tag and ensure that you explicitly put all your brackets, parenthesis and braces... I think ruby might be interpreting your URL string as a hash... Can you look at the HTML source generated and email it to us? Thanks Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 05/05/2010, at 11:04 PM, shaan ss <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi I have a strange problem, I am using the below code > > form_remote_tag :url => ''/abc/test'',:before => "return hello();", > :update=>''test_categories'' ,:complete => "Element.hide(''spinner'')", > :loading => "Element.show(''spinner'')" do > > I am using :before=> function to validate the fields in the form, but > the problem is that it does not update the div test_categories, instead > opens as a separate page like regular form. If I remove this :before=> > all works fine. > > > the function hello is below and just a normal js > function hello() > { > > if(document.getElementById("card_no").value=="") > { > alert("Card not captured, please try again") > document.getElementById("card_no").focus() > return false; > } > return true; > } > > > Any Ideas? > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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.
Hi again, The problem is that before => does not prevent form submission and Julian was right about the inclusion of the return. However removing the return runs the JavaScript hello() function but does not cancel form submission. Instead you should use the :condition => filter; :condition => "$(''card_no'').value != ''''", This will check the value of card_no and if empty will not submit the form, otherwise the form is submitted and the test_categories div updated. If any of the JavaScript code is invalid then a standard http request will be made. This is why it opens a separate page like regular form. On 5 May, 13:04, shaan ss <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi I have a strange problem, I am using the below code > > form_remote_tag :url => ''/abc/test'',:before => "return hello();", > :update=>''test_categories'' ,:complete => "Element.hide(''spinner'')", > :loading => "Element.show(''spinner'')" do > > I am using :before=> function to validate the fields in the form, but > the problem is that it does not update the div test_categories, instead > opens as a separate page like regular form. If I remove this :before=> > all works fine. > > the function hello is below and just a normal js > function hello() > { > > if(document.getElementById("card_no").value=="") > { > alert("Card not captured, please try again") > document.getElementById("card_no").focus() > return false; > } > return true; > } > > Any Ideas? > -- > Posted viahttp://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@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.
Dont use return. If you have something to validate before ajax call then do it using :condition option. Moving the hello js call in :condition option should solve your problem. -----Original Message----- From: Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> Sent: Wednesday, 5 May 2010 10:53 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Cc: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Subject: Re: [Rails] form remote tag :before=> function problem The other thing i''d suggest is to look up the API for form remote tag and ensure that you explicitly put all your brackets, parenthesis and braces... I think ruby might be interpreting your URL string as a hash... Can you look at the HTML source generated and email it to us? Thanks Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 05/05/2010, at 11:04 PM, shaan ss <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi I have a strange problem, I am using the below code > > form_remote_tag :url => ''/abc/test'',:before => "return hello();", > :update=>''test_categories'' ,:complete => "Element.hide(''spinner'')", > :loading => "Element.show(''spinner'')" do > > I am using :before=> function to validate the fields in the form, but > the problem is that it does not update the div test_categories, instead > opens as a separate page like regular form. If I remove this :before=> > all works fine. > > > the function hello is below and just a normal js > function hello() > { > > if(document.getElementById("card_no").value=="") > { > alert("Card not captured, please try again") > document.getElementById("card_no").focus() > return false; > } > return true; > } > > > Any Ideas? > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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 [The entire original message is not included] -- 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.