Hi,
Has anyone successfully implemented the :onsubmit option for
form_remote_tag. It doesn''t seem to work for me. Is there any specific
version of rails which is required for the same.
Here''s my piece of code.
<script>
function set_tojid(){
alert(''onsubmit'');
}
</script>
<%= form_remote_tag :update => '''', :url => { :action
=> ''''}, :onsubmit
=> "set_tojid()", :after => "clearinput()" %>
<%= text_field_tag :newmessage, nil, {:style => "width:
100%", :maxlength => "1000",:autocomplete =>
"off"} %>
<%= hidden_field_tag :send_to, value = '''' %>
<%= end_form_tag %>
Anything buggy here??
TIA
~Shishir
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 10/3/07, Shishir Srivastava <shishir.srivastava-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > Has anyone successfully implemented the :onsubmit option for > form_remote_tag. It doesn''t seem to work for me. Is there any specific > version of rails which is required for the same. > > Here''s my piece of code. > > <script> > function set_tojid(){ > alert(''onsubmit''); > } > </script> > <%= form_remote_tag :update => '''', :url => { :action => ''''}, :onsubmit > => "set_tojid()", :after => "clearinput()" %> > <%= text_field_tag :newmessage, nil, {:style => "width: > 100%", :maxlength => "1000",:autocomplete => "off"} %> > <%= hidden_field_tag :send_to, value = '''' %> > <%= end_form_tag %> > > Anything buggy here??Lots. 1. You can''t use :onsubmit, because form_remote_tag generates an onsubmit attribute. You should use :before instead, which will place your code in the onsubmit event before the Ajax call. 2. Why are you using :update without an id? If your view is doing RJS, you should leave :update off, which generates Ajax.Request instead of Ajax.Updater. 3. Using the non-block form is deprecated. Try this: <% form_remote_tag :url => { :action => ''''}, :before => "set_tojid()", :after => "clearinput()" do %> ...blah blah <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks a lot Bob for cleaning the code. I was actually wary of
using :before as a substitute of :onsubmit. Anyways, I need one more
help. I am actually trying to update the value of one of my hidden
parameters in the form, before submitting like this. Again it seems
i''ve hit a road block.
<script>
function set_tojid(){
document.getElementById(''send_to'').value=''newvalue''
}
</script>
<%= form_remote_tag :name => ''minput'', :url => {
:action =>
''''}, :before => "set_tojid()", :after =>
"clearinput()" %>
<%= text_field_tag :newmessage, nil, {:style => "width:
100%", :maxlength => "1000",:autocomplete =>
"off"} %>
<%= hidden_field_tag :send_to, value = ''oldvalue'' %>
<%= end %>
I have checked the parameters in the post , and the :send_to parameter
still hold the oldvalue.
:(
~Shishir
On Oct 3, 7:55 pm, "Bob Showalter"
<showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 10/3/07, Shishir Srivastava
<shishir.srivast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
>
>
> > Hi,
>
> > Has anyone successfully implemented the :onsubmit option for
> > form_remote_tag. It doesn''t seem to work for me. Is there any
specific
> > version of rails which is required for the same.
>
> > Here''s my piece of code.
>
> > <script>
> > function set_tojid(){
> > alert(''onsubmit'');
> > }
> > </script>
> > <%= form_remote_tag :update => '''', :url =>
{ :action => ''''}, :onsubmit
> > => "set_tojid()", :after => "clearinput()"
%>
> > <%= text_field_tag :newmessage, nil, {:style => "width:
> > 100%", :maxlength => "1000",:autocomplete =>
"off"} %>
> > <%= hidden_field_tag :send_to, value = '''' %>
> > <%= end_form_tag %>
>
> > Anything buggy here??
>
> Lots.
>
> 1. You can''t use :onsubmit, because form_remote_tag generates an
> onsubmit attribute. You should use :before instead, which will place
> your code in the onsubmit event before the Ajax call.
>
> 2. Why are you using :update without an id? If your view is doing RJS,
> you should leave :update off, which generates Ajax.Request instead of
> Ajax.Updater.
>
> 3. Using the non-block form is deprecated.
>
> Try this:
>
> <% form_remote_tag :url => { :action => ''''},
> :before => "set_tojid()", :after =>
"clearinput()" do %>
>
> ...blah blah
>
> <% end %>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 3 Oct 2007, at 16:15, Shishir Srivastava wrote:> > Thanks a lot Bob for cleaning the code. I was actually wary of > using :before as a substitute of :onsubmit. Anyways, I need one more > help. I am actually trying to update the value of one of my hidden > parameters in the form, before submitting like this. Again it seems > i''ve hit a road block. >I''d recommend using firebug''s javascript debugger to step through this and see exactly what''s happening Fred> <script> > function set_tojid(){ > document.getElementById(''send_to'').value=''newvalue'' > } > </script> > > <%= form_remote_tag :name => ''minput'', :url => { :action => > ''''}, :before => "set_tojid()", :after => "clearinput()" %> > <%= text_field_tag :newmessage, nil, {:style => "width: > 100%", :maxlength => "1000",:autocomplete => "off"} %> > <%= hidden_field_tag :send_to, value = ''oldvalue'' %> > <%= end %> > > I have checked the parameters in the post , and the :send_to parameter > still hold the oldvalue. > > :( > > ~Shishir > > > > On Oct 3, 7:55 pm, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 10/3/07, Shishir Srivastava <shishir.srivast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >> >> >>> Hi, >> >>> Has anyone successfully implemented the :onsubmit option for >>> form_remote_tag. It doesn''t seem to work for me. Is there any >>> specific >>> version of rails which is required for the same. >> >>> Here''s my piece of code. >> >>> <script> >>> function set_tojid(){ >>> alert(''onsubmit''); >>> } >>> </script> >>> <%= form_remote_tag :update => '''', :url => { :action => >>> ''''}, :onsubmit >>> => "set_tojid()", :after => "clearinput()" %> >>> <%= text_field_tag :newmessage, nil, {:style => "width: >>> 100%", :maxlength => "1000",:autocomplete => "off"} %> >>> <%= hidden_field_tag :send_to, value = '''' %> >>> <%= end_form_tag %> >> >>> Anything buggy here?? >> >> Lots. >> >> 1. You can''t use :onsubmit, because form_remote_tag generates an >> onsubmit attribute. You should use :before instead, which will place >> your code in the onsubmit event before the Ajax call. >> >> 2. Why are you using :update without an id? If your view is doing >> RJS, >> you should leave :update off, which generates Ajax.Request instead of >> Ajax.Updater. >> >> 3. Using the non-block form is deprecated. >> >> Try this: >> >> <% form_remote_tag :url => { :action => ''''}, >> :before => "set_tojid()", :after => "clearinput()" do %> >> >> ...blah blah >> >> <% end %> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Fred, I almost forgot that feature of firebug !! On Oct 3, 8:20 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 Oct 2007, at 16:15, Shishir Srivastava wrote: > > > > > Thanks a lot Bob for cleaning the code. I was actually wary of > > using :before as a substitute of :onsubmit. Anyways, I need one more > > help. I am actually trying to update the value of one of my hidden > > parameters in the form, before submitting like this. Again it seems > > i''ve hit a road block. > > I''d recommend using firebug''s javascript debugger to step through > this and see exactly what''s happening > > Fred > > > <script> > > function set_tojid(){ > > document.getElementById(''send_to'').value=''newvalue'' > > } > > </script> > > > <%= form_remote_tag :name => ''minput'', :url => { :action => > > ''''}, :before => "set_tojid()", :after => "clearinput()" %> > > <%= text_field_tag :newmessage, nil, {:style => "width: > > 100%", :maxlength => "1000",:autocomplete => "off"} %> > > <%= hidden_field_tag :send_to, value = ''oldvalue'' %> > > <%= end %> > > > I have checked the parameters in the post , and the :send_to parameter > > still hold the oldvalue. > > > :( > > > ~Shishir > > > On Oct 3, 7:55 pm, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 10/3/07, Shishir Srivastava <shishir.srivast...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> Hi, > > >>> Has anyone successfully implemented the :onsubmit option for > >>> form_remote_tag. It doesn''t seem to work for me. Is there any > >>> specific > >>> version of rails which is required for the same. > > >>> Here''s my piece of code. > > >>> <script> > >>> function set_tojid(){ > >>> alert(''onsubmit''); > >>> } > >>> </script> > >>> <%= form_remote_tag :update => '''', :url => { :action => > >>> ''''}, :onsubmit > >>> => "set_tojid()", :after => "clearinput()" %> > >>> <%= text_field_tag :newmessage, nil, {:style => "width: > >>> 100%", :maxlength => "1000",:autocomplete => "off"} %> > >>> <%= hidden_field_tag :send_to, value = '''' %> > >>> <%= end_form_tag %> > > >>> Anything buggy here?? > > >> Lots. > > >> 1. You can''t use :onsubmit, because form_remote_tag generates an > >> onsubmit attribute. You should use :before instead, which will place > >> your code in the onsubmit event before the Ajax call. > > >> 2. Why are you using :update without an id? If your view is doing > >> RJS, > >> you should leave :update off, which generates Ajax.Request instead of > >> Ajax.Updater. > > >> 3. Using the non-block form is deprecated. > > >> Try this: > > >> <% form_remote_tag :url => { :action => ''''}, > >> :before => "set_tojid()", :after => "clearinput()" do %> > > >> ...blah blah > > >> <% end %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- form_remote_tag : additional onsubmit funct. possible ?
- [Prototype] Why doesn''t calling submit() on a form result in the execution of the onsubmit event handler?
- Using onSubmit tag in form_tag?
- onsubmit for remote_form_for not working properly
- form_for onsubmit