# That ol' AJAX select box update again : observe\_field does n

**URL:** <https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697>\
**Category:** Rails\
**Created:** [January 18, 2006, 2:06am UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697 "2006-01-18T02:06:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [January 18, 2006, 2:06am UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697/1 "2006-01-18T02:06:46Z")

</div>

Hi,  
I know this has been asked a million times before - but I still don’t  
really get it. CAn someone please tell me what’s up with the following;

In a view I have (apologies for the formatting);

```
			<td>
				<select id="job.job_phase_id" name="job[job_phase_id]"><p><label

```

for=“job\_job\_phase\_id”\>Job Phase  
  
\<%= options\_from\_collection\_for\_select @jp, “id”, “description”,  
job.job\_phase\_id %\>

  

  
  
\<%= observe\_field(?job.job\_phase\_id?,  
:frequency =\> 0.25,  
:update =\> ?action\_container?,  
:url =\> { :controller =\> ‘job’, :action =\>  
:get\_action\_from\_phase },  
:with =\> ??job\_phase\_id=?+value?) %\>

```
			<td id='action_container'>
				<select id="job.current_action_id"

```

name=“job[current\_action\_id]”\>

Job  
Phase  
  
\<%= options\_from\_collection\_for\_select @ja, “id”, “description”,  
job.current\_action\_id %\>

  

  

In the controller this;  
def get\_action\_from\_phase  
breakpoint  
@ja = ActionType.find(:all, :conditions =\> [‘job\_phase\_id = ?’,  
params[job\_phase\_id]])  
end

The prototype.js is called at the head of the shell page ;

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”  
“[http://www.w3.org/TR/html4/loose.dtd](http://www.w3.org/TR/html4/loose.dtd)”\>

 The Manias Project \<%= stylesheet\_link\_tag "manias", :media =\> "all" %\> \<%= javascript\_include\_tag "dojo" %\> \<%= javascript\_include\_tag "prototype" %\> The result is that the breakpoint in the controller is never called - so observe\_field is doing nothing

Kind Regards,  
Eric

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [January 18, 2006, 3:07am UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697/2 "2006-01-18T03:07:07Z")

</div>

Are you checking the logs to see if anything is getting generated when  
you make a change? It could be that the breakpointer isn’t working  
right. Check the logs first to confirm. I have an observe\_field on a  
select box that I just did the other night and its working great and  
looks very similar to what you have.

The only thing I question is the use of the “.” in the id. I’m not  
sure if that would screw it up at all or not. Don’t know how it would,  
but you never know.

-Nick "never forget the `tail -f` " S

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [January 18, 2006, 4:49am UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697/3 "2006-01-18T04:49:42Z")

</div>

Hi Nick,  
No - nothing in the logs at all. Maybe you could post your version of  
select/observe?  
Cheers,  
Eric.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [January 18, 2006, 3:19pm UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697/4 "2006-01-18T15:19:46Z")

</div>

Yep, here’s what I got:

\<%= select “object”, “some\_id”, @list\_stuff\_here %\>  
\<%= observe\_field(“object\_some\_id”, :frequency =\> 0.25, :url =\> {  
:controller =\> “objects”, :action =\> “change\_something”, :id =\> @object  
},  
:with =\> “‘some\_id=’+value”) %\>

In my layout I do \<%= javascript\_include\_tag :defaults %\>

Thats pretty much it. I do have an :update attribute because I am using  
RJS  
templates do update the views instead. It should still work fine with  
the  
:update in there.

-Nick

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [January 19, 2006, 12:53am UTC](https://www.ruby-forum.com/t/that-ol-ajax-select-box-update-again-observe-field-does-n/52697/5 "2006-01-19T00:53:59Z")

</div>

Thanks Nick!  
I have it working after a fashion - but I have an extra twist - the page  
I’m working on is actually a table where each row is a form in itself.  
I’m having trouble identifying or limiting the observe/update within  
each row/form.  
Cheers,  
Eric.
