In my header I have a drop-down to change the language, inside a form I would like to submit the form without any submit button, just upon selection changing this his the generated code from my haml code <form onchange="this.form.submit();" method="post" action="/ switch_language?locale=fr"> <select name="language[]" id="language_"><option value="en">Anglais</ option> <option selected="selected" value="fr">Français</option> <option value="de">Allemand</option></select> </form> but I get a JS error this.form is undefined what did I missed ... thanks for your help -- 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.
> > this his the generated code from my haml code > > <form onchange="this.form.submit();" method="post" action="/ > switch_language?locale=fr"> > <select name="language[]" id="language_"><option value="en">Anglais</ > option> > <option selected="selected" value="fr">Français</option> > <option value="de">Allemand</option></select> > </form> > > but I get a JS error > > this.form is undefined > > what did I missed ... >The onchange event is on the <form> tag, so "this" is a form and doesn''t have a ".form" method. Try doing: <form onchange="this.submit();"... P.S. It does feel icky having onchange="" in your markup, but let''s worry about going to Unobtrusive Javascript later... Cheers, Andy -- 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.
On Fri, Jul 9, 2010 at 8:35 AM, Andy Jeffries <andy-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote:> The onchange event is on the <form> tag, so "this" is a form and doesn''t > have a ".form" method. Try doing: > <form onchange="this.submit();"...Actually, a form element doesn''t have an "onchange" event handler -- you want to put that on the select, referring to the parent form... -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.
Good catch Hassan -- Andy Jeffries http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS Company number: 5452840 -- 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.
Thanks Hassan I modified my code ( onchange is now on the select ) but it seems not to be working ... I don''t have a submit submit button ... should I add a submit button w display:none ? On 9 juil, 17:40, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Jul 9, 2010 at 8:35 AM, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: > > The onchange event is on the <form> tag, so "this" is a form and doesn''t > > have a ".form" method. Try doing: > > <form onchange="this.submit();"... > > Actually, a form element doesn''t have an "onchange" event handler -- > you want to put that on the select, referring to the parent form... > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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.
Ok it runs ... I did a mistake copying the :html => { :onchange ... into the select I had to write only :onchange... into the select good Thanks a lot have a nice we On 9 juil, 17:40, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Jul 9, 2010 at 8:35 AM, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: > > The onchange event is on the <form> tag, so "this" is a form and doesn''t > > have a ".form" method. Try doing: > > <form onchange="this.submit();"... > > Actually, a form element doesn''t have an "onchange" event handler -- > you want to put that on the select, referring to the parent form... > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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.
On Fri, Jul 9, 2010 at 8:52 AM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> I modified my code ( onchange is now on the select ) > but it seems not to be working ...Are you using Firefox with Firebug? If not, you should be, because it''s very good at reporting errors. :-) What does your generated form html look like now? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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.