Forum: Ruby on Rails That ol' AJAX select box update again : observe_field does n

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.
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-01-18 02:06
(Received via mailing list)
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</label><br/>
						<%= options_from_collection_for_select @jp, "id", "description",
job.job_phase_id  %></p>
					</select></p>
				</td>
				<%= 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]"><p><label for="job_current_action_id">Job
Phase</label><br/>
						<%= options_from_collection_for_select @ja, "id", "description",
job.current_action_id  %></p>
					</select></p>
				</td>

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">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
		<title>The Manias Project</title>
		<%= stylesheet_link_tag "manias", :media => "all" %>
		<%= javascript_include_tag "dojo" %>
	    <%= javascript_include_tag "prototype" %>
	</head>
The result is that the breakpoint in the controller is never called - so
observe_field is doing nothing

Kind Regards,
Eric
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-01-18 03:07
(Received via mailing list)
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
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-01-18 04:49
(Received via mailing list)
Hi Nick,
No - nothing in the logs at all. Maybe you could post your version of
select/observe?
Cheers,
Eric.
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-01-18 15:19
(Received via mailing list)
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
17d01ff4326c26911481c7a77283b343?d=identicon&s=25 Eric Sloane (Guest)
on 2006-01-19 00:53
(Received via mailing list)
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.
This topic is locked and can not be replied to.