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.
<%= 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
On 10/3/07, Shishir S. [email protected] wrote:
function set_tojid(){
Anything buggy here??
Lots.
-
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.
-
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.
-
Using the non-block form is deprecated.
Try this:
<% form_remote_tag :url => { :action => ‘’},
:before => “set_tojid()”, :after => “clearinput()” do %>
...blah blah
<% end %>
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.
<%= 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 3 Oct 2007, at 16:15, Shishir S. 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
Thanks Fred, I almost forgot that feature of firebug !!
On Oct 3, 8:20 pm, Frederick C. [email protected]