If I write a GET AJAX request using remote function, how can I configure
it to pass the values of form fields.
Assume that I have a ZIP code field in a form, and I write something
like this:
remote_function(:url => {:action =>
''lookup_city_and_state'',
:object_name => object_name,
:check_state => check_state ? ''1''
: ''0'',
:mailing => mailing ? ''1'' :
''0''})
how would I pass the form value from my ZIP code field - or can it be
done?
I already have the Javascript version of this AJAX request working but
was wondering if I could use the remote_function idiom instead.
Thanks,
Wes
--
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
-~----------~----~----~----~------~----~------~--~---
Wes,
Did you try the :with option?
e.g
:onclick => remote_function(
:url => {:action => :preview},
#:with =>
"''name_of_form_field''=value_you_want_and_javascript_is_legal"
:with =>
"''patch[editing_rdoc]=''+$(''patch_modified_rdoc_source'').value",
:before =>
"$(''preview_target'').innerHTML=''..loading..''",
:failure =>
"$(''preview_target'').innerHTML=''Ajax
error!''",
:update => ''preview_target''
) + '';return false;''
--Jinal
Wes Gamble wrote:> If I write a GET AJAX request using remote function, how can I configure
> it to pass the values of form fields.
>
> Assume that I have a ZIP code field in a form, and I write something
> like this:
>
> remote_function(:url => {:action =>
''lookup_city_and_state'',
> :object_name => object_name,
> :check_state => check_state ?
''1'' : ''0'',
> :mailing => mailing ? ''1'' :
''0''})
>
> how would I pass the form value from my ZIP code field - or can it be
> done?
>
> I already have the Javascript version of this AJAX request working but
> was wondering if I could use the remote_function idiom instead.
>
> Thanks,
> Wes
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---
Also you can use the submit option
<%= submit_tag ''Save'', :name =>
''save'', :id => ''save'' %>
<%= submit_tag ''Update Preview'',
:name => ''preview'',
:onclick => remote_function(
:url => {:action => :preview, :_method => :post},
:submit => "id_of_my_form",
:before =>
"$(''preview_target'').innerHTML=''..loading..''",
:failure =>
"$(''preview_target'').innerHTML=''Ajax
error!''",
:update => ''preview_target''
) + '';return false;''
%>
Read http://www.timocracy.com/articles/tag/remote_function for detailed
information on various ways of doing this.
--Jinal Jhaveri
http://jjhaveri.googlepages.com/
Wes Gamble wrote:> If I write a GET AJAX request using remote function, how can I configure
> it to pass the values of form fields.
>
> Assume that I have a ZIP code field in a form, and I write something
> like this:
>
> remote_function(:url => {:action =>
''lookup_city_and_state'',
> :object_name => object_name,
> :check_state => check_state ?
''1'' : ''0'',
> :mailing => mailing ? ''1'' :
''0''})
>
> how would I pass the form value from my ZIP code field - or can it be
> done?
>
> I already have the Javascript version of this AJAX request working but
> was wondering if I could use the remote_function idiom instead.
>
> Thanks,
> Wes
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---
Jinal, Thanks. I thought :with might work but didn''t see it in the API docs. Generally, I find that finding a true comprehensive list of Prototype API function parameters, or finding a comprehensive list of RoR AJAX-y function parameters can be somewhat challenging. I wonder if anyone is working on a _complete_ Prototype/Script.aculo.us reference? Anyhow, thanks again, all works great. Wes -- 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 -~----------~----~----~----~------~----~------~--~---