That ol' AJAX select box update again : observe_field does n


#1

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”>

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


#2

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


#3

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


#4

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


#5

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.