Forum: Ruby on Rails getValue() in a Controller problem, help please.

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.
56b63ca3f149742bc54e54c8f07cc9c7?d=identicon&s=25 David Sousa (mrsousa)
on 2009-01-23 01:00
Hello there,

I'm trying to do something like:

render :update do |page|
    page[:client_list].replace_html render(:partial => 'client_list',
:object => @clients_list)
    name = page[:name].getValue();
end

but I'm not getting the value, or somehow use $("name").getValue()
inside of the controller.

How can I do that?

tks,

David Sousa
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2009-01-23 10:47
(Received via mailing list)
David Sousa wrote:
> but I'm not getting the value, or somehow use $("name").getValue()
> inside of the controller.

You will need to send this value as a parameter of your AJAX
call, using the :with parameter of the form helper.

--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
56b63ca3f149742bc54e54c8f07cc9c7?d=identicon&s=25 David Sousa (mrsousa)
on 2009-01-23 21:09
Hello Mark, thanks... but, my problem is bigger than that or I don't
know how that the answer is easy.

So, I have a structure like this. (view)

<div id="my_client_list">
    <% @client_list.each do |client| -%>
        <%= client.name%>
        ....... .. .. .. ..
    <% end -%>
<%=will_paginate(@client_list, :params => {:controller => "client",
:action => "search_result", :foo => "$F('name')"})%>
</div>

<div id="search_form_div">
    <form class="sidebar-search-companies" id= 'search_form'>
  <label for="nome">Nome</label>
  <%= text_field_tag :name%>
  .... .... ...
    </form>
    <%= observe_form :search_form, :frequency => 0.5, :url => { :action
=> "search_result" } %>
</div>


What I wanna do is, pass the :name.value of the search form to the
paginate action, so when the result is paginated I will still have the
same results. Otherwise, when I go the the second page for example, I
will have the second page of all my clients, not the result of the
search.

Sounds confusing... did you understand?


Tks,

David Sousa
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2009-01-25 04:54
(Received via mailing list)
David Sousa wrote:
> <%=will_paginate(@client_list, :params => {:controller => "client",
> => "search_result" } %>
> </div>
>
>
> What I wanna do is, pass the :name.value of the search form to the
> paginate action, so when the result is paginated I will still have the
> same results. Otherwise, when I go the the second page for example, I
> will have the second page of all my clients, not the result of the
> search.

Since you're using observe_form, params[:name] will be set
in your controller action, which can be used in the view.
e.g. :foo => params[:name]

--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
56b63ca3f149742bc54e54c8f07cc9c7?d=identicon&s=25 David Sousa (mrsousa)
on 2009-01-25 19:12
Hello Mark James,
thank you very much, it worked, and was easy... lol.
I'm getting used to rails....


tks,

David Sousa
This topic is locked and can not be replied to.