I posted this to the new Prototype Scriptaculous group yesterday, but
realized that someone with suggestions might not have made the switch.
I'd appreciate any ideas.
---------- Forwarded message ----------
From: Rick DeNatale <rick.denatale@gmail.com>
Date: Mon, Jul 7, 2008 at 2:56 PM
Subject: Can't figure out why Javascript is executing in one ajax
request
but not another.
To: prototype-scriptaculous@googlegroups.com
I've run out of ideas on this one.
I've got two rails controllers which are sharing some partials and ajax
code.
One partial generates a pair of select elements one for country, and
another
for timezones. It also generates an observer with:
<%= observe_field @user.dom_id('country_code'),
:url => {:action =>
'ajax_update_timezone_select_with_new_zones_for_selected_country',
:timezoneable_type => 'User',
:timezoneable_id => @user.id}, :method => :get, :with =>
'country_code' %>
The ajax_update_timezone_select_with_new_zones_for_selected_country
action
is defined in a module mixed in to both controllers. It renders an rjs
template in which I've added an alert for debugging purposes:
page << 'alert("done");'
page.replace @entity.dom_id('timezone'), :partial =>
'/mixins/timezone/timezone_select', :locals => {:country_code =>
@country_code}
Now this works find in one controller, when I make a selection in the
country_code selection list the observer fires, the alert comes up, and
the
timezone list is updated.
In the other controller the observer fires, the same response comes
back,
but nothing happens! No alert, no update.
Firebug, shows the same response in both cases. I've tried this both in
Firefox and Safari and it seems browser independent.
I've gone so far as to cut and paste what firebug is showing in the
console
along with the script tags for the observer, saving to two files and
doing a
diff between the two, and the only things which is changing are
timestamps,
and the hostname.
The hostname changes because we use different virtual hostnames to
provide
contexts in our app. However, as far as I can tell the hostname is
consistent between each response request pair, and the page containing
the
partial.
Any ideas on why Javascript is being executed in one case and thrown
away in
the other?
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
on 2008-07-08 13:07
on 2008-07-08 13:19
@Rick: If you're going to cross-post (and I understand why you would want to), best to just point people at the new thread rather than reposting the entire question. We're trying to move *away* from this group, remember. @All: The thread is here: http://groups.google.com/group/prototype-scriptacu... -- T.J. Crowder tj / crowder software / com