Hello, I seem to be having a strange problem. I have a form_remote_tag which i submit using a javascript call: if(document.forms[''myform''].onsubmit()) { document.forms[''myform''].submit(); } This works great the first time the call is made - however the second time it doesn''t seem to work - the form seems to have disappeared and have no properties. I then need to refresh the page and it work again, then doesn''t work on the second attempt, again.. Any ideas? Do i have to reload the page after using ajax to submit a form, in order to re-use the form? Thanks for your time -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James, sounds like you''re your :update is writing over your form look at the partial you''re rendering, and the contents, and what div your rendering too - likely you''re rendering to an ID outside the form_tag, with a partial that doesn''t contain the form_tag. Jodi On Feb 24, 7:43 am, James Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > > I seem to be having a strange problem. I have a form_remote_tag which i > submit using a javascript call: > > if(document.forms[''myform''].onsubmit()) { > document.forms[''myform''].submit(); } > > This works great the first time the call is made - however the second > time it doesn''t seem to work - the form seems to have disappeared and > have no properties. I then need to refresh the page and it work again, > then doesn''t work on the second attempt, again.. > > Any ideas? > > Do i have to reload the page after using ajax to submit a form, in order > to re-use the form? > > Thanks for your time > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James - on second thought it might be the opposite ( you''re rendering the form_tag twice ) but your best bet, sort of a teach a man to fish, is to pickup [1]firebug - you''ll sleep better. Jodi [1] https://addons.mozilla.org/firefox/1843/ On Feb 24, 10:07 am, "Jodi" <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote:> James, sounds like you''re your :update is writing over your form > > look at the partial you''re rendering, and the contents, and what div > your rendering too - likely you''re rendering to an ID outside the > form_tag, with a partial that doesn''t contain the form_tag. > > Jodi > > On Feb 24, 7:43 am, James Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Hello, > > > I seem to be having a strange problem. I have a form_remote_tag which i > > submit using a javascript call: > > > if(document.forms[''myform''].onsubmit()) { > > document.forms[''myform''].submit(); } > > > This works great the first time the call is made - however the second > > time it doesn''t seem to work - the form seems to have disappeared and > > have no properties. I then need to refresh the page and it work again, > > then doesn''t work on the second attempt, again.. > > > Any ideas? > > > Do i have to reload the page after using ajax to submit a form, in order > > to re-use the form? > > > Thanks for your time > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> but your best bet, sort of a teach a man to fish, is to pickup > [1]firebug - you''ll sleep better. > > Jodi > [1] https://addons.mozilla.org/firefox/1843/Thanks for this, this seems like a great tool. When i submit the form on the second time i am getting errors in the console. The first error is as follows: this.element has no properties (no name)(undefined)prototype.js (line 265) _each(function())prototype.js (line 456) each(function())prototype.js (line 261) collect(function())prototype.js (line 293) invoke("loop")prototype.js (line 349) loop()effects.js (line 239) bind()prototype.js (line 48) [Break on this error] if(this.element.getStyle(''display'')==''none'') { this.cancel(); return; } and then the console is repeatedly throwing the following error: this.element has no properties [Break on this error] this.element.setStyle({backgroundColor: $R(0,2).inject(''#'',function(m,v,i){ and so it keeps going repeatedly throwing the latter error.. So from this i gather that it cannot find the form element.. but then i''m not sure how i can read further into this and solve my problem, 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey James - I suggest that it''s the first submit that''s causing the problem (symptom) you''re seeing, when you try to submit it the second time. Follow the logic carefully #1. what is the ID that your form result is rendering to? (:update => ''id'') #2. what partial is being rendered by your controller? What is inside this partial? #3. what is currently inside that ID? (on the first render) I suggest that one of 2 things is happening: A. the partial being rendered by the controller (in #2) is rendering a second form - if this form is inside the current form, or has the same ID then the Second Form Submit will fail to work B. the partial being rendered is not rendering the Form Tag - and so when you click to submit, the form cannot be found. this will take some investigation on your part. But if you are careful you should be able to find out the confusion - and learn a valuable lesson on the way. Jodi On Feb 24, 5:35 pm, James Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > but your best bet, sort of a teach a man to fish, is to pickup > > [1]firebug - you''ll sleep better. > > > Jodi > > [1] https://addons.mozilla.org/firefox/1843/ > > Thanks for this, this seems like a great tool. > > When i submit theformon thesecond timei am getting errors in the > console. > The first error is as follows: > > this.element has no properties > (no name)(undefined)prototype.js (line 265) > _each(function())prototype.js (line 456) > each(function())prototype.js (line 261) > collect(function())prototype.js (line 293) > invoke("loop")prototype.js (line 349) > loop()effects.js (line 239) > bind()prototype.js (line 48) > [Break on this error] if(this.element.getStyle(''display'')==''none'') { > this.cancel(); return; } > > and then the console is repeatedly throwing the following error: > > this.element has no properties > [Break on this error] this.element.setStyle({backgroundColor: > $R(0,2).inject(''#'',function(m,v,i){ > > and so it keeps going repeatedly throwing the latter error.. > > So from this i gather that it cannot find theformelement.. but then > i''m not sure how i can read further into this and solve my problem, 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Finally, i have discovered my wrongs.. I was using effects.js in my rjs file to highlight the form after it had been submitted, and this was causing the form to effectively disappear. Why it took me so long to figure out i will never know.. Thanks for your help on this, firebug is a great tool. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---