Observe_field

I have been trying to pass a collection_select parameter and a text
field
parameter to observe_field so that it watches both the parameters
simultaneously.

but what i can see is , when i select some value from drop down and dont
write anything in text field its giving correct results.parameters are
also
correct passed, but just after that if i write something in text field
that
value also get passed as collection_select parameter(labtid in my case)
my view code is:


Filter on Device Name :
<%= text_field_tag(“query”, params[‘query’], :size => 10 )%>

Lab :
<%= collection_select(:labt, :labtid,
@labs, :id, :name,:prompt => “Select a Lab”) %>

<%= image_tag("spinner.gif", :align => "absmiddle", :border => 0, :id => "spinner", :style =>"display: none;" ) %>

<%= javascript_include_tag :defaults %>

<%= observe_field ‘query’, :frequency => 2,
:update => “table”,
:before => “Element.show(‘spinner’)”,
:success => “Element.hide(‘spinner’)”,
:url => {:action => ‘trial_location1’},
:with => “‘labtid=’ + value+‘&query=’+escape($(‘query’).value)”
%>
<%= observe_field ‘labt_labtid’, :frequency => 2,
:update => “table”,
:before => “Element.show(‘spinner’)”,
:success => “Element.hide(‘spinner’)”,
:url => {:action => ‘trial_location1’},

     :with => "'labtid=' + value+'&query='+escape($('query').value)"

   %>
<%= render :partial => "devices_list" %>

i believe the problem lies with :with parameter.
Can someone suggest me the problem?
Thanking in advance!!

View this message in context:
http://www.nabble.com/observe_field-tp18009235p18009235.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

On 19 Jun 2008, at 14:38, sup wrote:

are also
:url => {:action => ‘trial_location1’},
:with => “‘labtid=’ + value+’&query=’+escape($
(‘query’).value)” %>
In the context of an observe_field, value is the value of the observed
field (so $(‘query’).value in this case, and $(‘labt_labtid’) in the
other, so you need to swap things around in the above observe_form
(the other one is fine)
Might observe_form not be less hassle in this case ?

Fred

u mean it should be like this ?
:with => “‘labt_labtid=’ + value+’&query=’+escape($(‘query’).value)”

On Thu, Jun 19, 2008 at 7:17 PM, Frederick C. <

On 19 Jun 2008, at 14:55, supriya agarwal wrote:

u mean it should be like this ?
:with => “‘labt_labtid=’ + value+’&query=’+escape($(‘query’).value)”

the observe field on labt_labtid should be like that, but not the
other one (again, it might be easier to have a single observe form)

Fred

On Jun 20, 5:59 am, “supriya agarwal” [email protected] wrote:

i tried doing it this way… its working fine…
also i think i should tell you that in my controller im accessing labtid as
params[:labtid] .
i tried putting params[:labt][:labtid] but then it completely failed.

You need to name the parameter labt[labtid] in your :with option if
you want to be able to access it as params[:labt][:labtid] as you do
when it’s submitted ‘normally’

can you help me here?? it would be great if you could put some sample code
for observe_form . i have no clue how it should work.!

It’s just like observe_field except you give it a form and it will
submit the whole form whenever any of it changes.

Fred

i tried doing it this way… its working fine…
also i think i should tell you that in my controller im accessing labtid
as
params[:labtid] .
i tried putting params[:labt][:labtid] but then it completely failed.

can you help me here?? it would be great if you could put some sample
code
for observe_form . i have no clue how it should work.!

Thanks again alot!

On Thu, Jun 19, 2008 at 7:39 PM, Frederick C. <