Forum: Ruby on Rails Difficulty with params hash and submit_to_remote

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B78b4458991fb48b4cc0e9defb488730?d=identicon&s=25 Stan McFarland (Guest)
on 2006-03-08 17:05
(Received via mailing list)
Hi,

Is there any trick to initializing the params hash via
submit_to_remote()?  I
have a form with two submit methods - the regular, non-AJAX method, and
the
AJAX method.  The regular method works like a champ.  The
submit_to_remote
invokes the correct controller, but the params hash is empty except for
the
values for :action and :controller.

I'd show my code, but it's on an internal network and I can't
cut-and-paste.

Thanks,

-stan
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-08 17:51
(Received via mailing list)
Nothing magic here, just add the other parameters to the remote_function
or link_to_remote calls like this..

<%= link_to_remote "Link", :update=>'updatediv',
:controller=>'controller', :action=>'action", :id=>object.id, :other
=>'other stuff' %>

Things like other should now be in the params array for the recieving
action

_Kevin
0d2c47bc04f33c4f548bd9e0bcc5e64f?d=identicon&s=25 Stan McFarland (Guest)
on 2006-03-08 19:19
Kevin Olbrich wrote:
> Nothing magic here, just add the other parameters to the remote_function
> or link_to_remote calls like this..

ok, I'm confused (but I *am* a newbie!). I thought the whole idea with
submit_to_remote() was to make the contents of a form available to the
controller in the params hash, just as if I had submitted it via
non-AJAX form.  Otherwise, I could have just called link_to_remote()
instead.

Any suggestions?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-08 20:13
(Received via mailing list)
It would help if I actually read your question right.

Take a close look at the API for submit_to_remote... if you also read
the docs for form_remote_tag.  This indicates that there is a way to set
it up to fallback to a normal submit if JS is disabled.  You shouldn't
need wo submit mechanisms.

I haven't actually used this yet, so I can't help much more than that.

_Kevin
0d2c47bc04f33c4f548bd9e0bcc5e64f?d=identicon&s=25 Stan McFarland (Guest)
on 2006-03-08 20:21
Kevin,

Thanks.  Believe it or not, it was a missing </div> tag in the view that
was preventing the form values from being passed.

-stan

Kevin Olbrich wrote:
> It would help if I actually read your question right.
>
> Take a close look at the API for submit_to_remote... if you also read
> the docs for form_remote_tag.  This indicates that there is a way to set
> it up to fallback to a normal submit if JS is disabled.  You shouldn't
> need wo submit mechanisms.
>
> I haven't actually used this yet, so I can't help much more than that.
>
> _Kevin
Cb816e71c90750565675cf63233d4db1?d=identicon&s=25 Christian Rolle (chrishawaii)
on 2007-01-12 11:42
Hi guys,

i've got the same problem. But in my situation I have to send values of
text-inputs via submit_to_remote() to my controller. I don't know how to
get the value of this text-input:
<%= text_field_with_auto_complete(:vorgang, :bez, {:value => '****'},
{:skip_style => true} ) %>

to my controller:

def filterDatensatz()
  tmp = params[:vorgang][:bez]
  my_redirect_to(:action => 'list', :tmp => tmp)
end

params[:vorgang] is always nil.

Can you help me?

Greetings
Chris
B5feafb2c66fdff60029deda63f99f93?d=identicon&s=25 dweinand (Guest)
on 2007-01-19 16:31
(Received via mailing list)
try something like this:

rhtml:
<%= text_field_with_auto_complete :person, :nachname, {},
  {
   :select => 'name',
   :after_update_element =>
     "function(element,value) " +
     "{ " +
     remote_function(:update=>'Kundendaten',
       :url=>{:action=>:update_kundendaten},
       :with=>"'adr_id='+value.id") + ";" +
     "}"
  }
  %>

controller:
def update_kundendaten
  #params[:adr_id] should be ok in controller
end

but with this solution i have the problem that the autocomplete is only
working on IE.
FF wont show the autocomplete popup. :(

HTH

On 12 Jan., 11:42, Christian Rolle <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.