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 <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]


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/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to