Hello, I try to use observe_field with select my code <%= observe_field :pay_zones, :on => "changed", :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" , :loading => "Element.show(''indicator'')", :complete => "Element.hide(''indicator'')" %> <label><%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> but i have a javascript error element has no properties getValue(null)prototype.js (line 3484) getValue()prototype.js (line 3673) initialize("pay_zones", function())prototype.js (line 3637) klass()prototype.js (line 50) [Break on this error] var method = element.tagName.toLowerCase(); http://beta.expay.local/javascripts/prototype.js?1194877354 Line 3484 where is my error ? thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12 Nov 2007, at 14:24, Bolo wrote:> > element has no properties > > getValue(null)prototype.js (line 3484) > getValue()prototype.js (line 3673) > initialize("pay_zones", function())prototype.js (line 3637) > klass()prototype.js (line 50) > [Break on this error] var method = element.tagName.toLowerCase(); > http://beta.expay.local/javascripts/prototype.js?1194877354 > Line 3484 > > where is my error ? >There is no DOM element on the page with id pay_zones Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> there is no DOM element on the page with id pay_zonesi think same thing like u but i have one <script type="text/javascript"> 1 2//<![CDATA[ 3new Form.Element.EventObserver(''pay_zones'', function(element, value) {new Ajax.Request(''/pays_distributeurs/sort'', {asynchronous:true, evalScripts:true, onComplete:function(request) {Element.hide(''indicator'')}, onLoading:function(request) {Element.show(''indicator'')}, parameters:''_method=put&tag=''+element.id +''&value=''+element.value})}, ''changed'') 4//]]> 5 </script> <label> <select id="pay_CodePays" name="pay[CodePays]"> </select> </label> <select id="pay_zones" class="combo_chage" prompt="Choisissez votre Départements" name="pay[zones]"> <option value="">Choissisez votre département</option> <option value="2">MARTINIQUE</option> <option value="97">HAUTS-DE-SEINE</option> </select> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Define the observe_field block after pay_zones. DOM can be picky about this kind of thing. Jason On Nov 12, 2007 9:54 AM, Bolo <malavoi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > there is no DOM element on the page with id pay_zones > > i think same thing like u but i have one > > <script type="text/javascript"> > 1 > 2//<![CDATA[ > 3new Form.Element.EventObserver(''pay_zones'', function(element, value) > {new Ajax.Request(''/pays_distributeurs/sort'', {asynchronous:true, > evalScripts:true, onComplete:function(request) > {Element.hide(''indicator'')}, onLoading:function(request) > {Element.show(''indicator'')}, parameters:''_method=put&tag=''+element.id > +''&value=''+element.value})}, ''changed'') > 4//]]> > 5 > </script> > <label> > <select id="pay_CodePays" name="pay[CodePays]"> > </select> > </label> > <select id="pay_zones" class="combo_chage" prompt="Choisissez votre > Départements" name="pay[zones]"> > <option value="">Choissisez votre département</option> > <option value="2">MARTINIQUE</option> > <option value="97">HAUTS-DE-SEINE</option> > </select> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12 Nov 2007, at 14:54, Bolo wrote:> >> there is no DOM element on the page with id pay_zones > > i think same thing like u but i have one >Oops, your observe_field needs to be after the thing it''s observing. Fred> <script type="text/javascript"> > 1 > 2//<![CDATA[ > 3new Form.Element.EventObserver(''pay_zones'', function(element, value) > {new Ajax.Request(''/pays_distributeurs/sort'', {asynchronous:true, > evalScripts:true, onComplete:function(request) > {Element.hide(''indicator'')}, onLoading:function(request) > {Element.show(''indicator'')}, parameters:''_method=put&tag=''+element.id > +''&value=''+element.value})}, ''changed'') > 4//]]> > 5 > </script> > <label> > <select id="pay_CodePays" name="pay[CodePays]"> > </select> > </label> > <select id="pay_zones" class="combo_chage" prompt="Choisissez votre > Départements" name="pay[zones]"> > <option value="">Choissisez votre département</option> > <option value="2">MARTINIQUE</option> > <option value="97">HAUTS-DE-SEINE</option> > </select> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
it''s works thank u :) On Nov 12, 11:28 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12 Nov 2007, at 14:54, Bolo wrote: > > > > >> there is no DOM element on the page with id pay_zones > > > i think same thing like u but i have one > > Oops, your observe_field needs to be after the thing it''s observing. > > Fred > > > <script type="text/javascript"> > > 1 > > 2//<![CDATA[ > > 3new Form.Element.EventObserver(''pay_zones'', function(element, value) > > {new Ajax.Request(''/pays_distributeurs/sort'', {asynchronous:true, > > evalScripts:true, onComplete:function(request) > > {Element.hide(''indicator'')}, onLoading:function(request) > > {Element.show(''indicator'')}, parameters:''_method=put&tag=''+element.id > > +''&value=''+element.value})}, ''changed'') > > 4//]]> > > 5 > > </script> > > <label> > > <select id="pay_CodePays" name="pay[CodePays]"> > > </select> > > </label> > > <select id="pay_zones" class="combo_chage" prompt="Choisissez votre > > Départements" name="pay[zones]"> > > <option value="">Choissisez votre département</option> > > <option value="2">MARTINIQUE</option> > > <option value="97">HAUTS-DE-SEINE</option> > > </select>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
craps it''s work but i have an other problem I use 3 selects and 3 observe_field. <label><%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => "Choisissez votre Départements", :class => ''combo_chage''}%> <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => "Choisissez votre Ville", :class => ''combo_chage''}%> <% end %> <%= observe_field :pay_CodePays, :on => "changed", :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" , :loading => "Element.show(''indicator'')", :complete => "Element.hide(''indicator'')" %> <%= observe_field :pay_zones, :on => "changed", :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id +''&value=''+element.value" , :loading => "Element.show(''indicator'')", :complete => "Element.hide(''indicator'')" %> <%= observe_field :pay_code_postaux, :on => "changed", :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id +''&value=''+element.value" , :loading => "Element.show(''indicator'')", :complete => "Element.hide(''indicator'')" %> When i change the first select , the action is correctly called. But i change the second select , no action is called. Nothing in firebug --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12 Nov 2007, at 16:44, Bolo wrote:> <label><%= select :pay, > :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , > {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> > <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, > c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => > "Choisissez votre Départements", :class => ''combo_chage''}%> > <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, > c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => > "Choisissez votre Ville", :class => ''combo_chage''}%> > <% end %> > <%= observe_field :pay_CodePays, > :on => "changed", > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" , > :loading => "Element.show(''indicator'')", > :complete => "Element.hide(''indicator'')" %> > > <%= observe_field :pay_zones, > :on => "changed", > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id > +''&value=''+element.value" , > :loading => "Element.show(''indicator'')", > :complete => "Element.hide(''indicator'')" %> > > <%= observe_field :pay_code_postaux, > :on => "changed", > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id > +''&value=''+element.value" , > :loading => "Element.show(''indicator'')", > :complete => "Element.hide(''indicator'')" %>Maybe if you would add a :url to your other observers? :-) Also, I''m seeing a lot of replication here for your ajax indicator. If u want to show the same indicator for all ajax requests, you''re much better off just putting the following code in your /public/ javascripts/application.js file: Ajax.Responders.register({ onCreate: function() { new Effect.Appear(''indicator'', { duration: 0.3 }); }, onComplete: function() { if (0 == Ajax.activeRequestCount) new Effect.Fade(''indicator'', { duration: 0.3 }); } }); Then just remove all those :loading and :complete calls. Also, you don''t need the :on => "changed" as that is what observe_field will default to when using selects. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Maybe if you would add a :url to your other observers? :-)my observers have all a :url I added the function in applications.js and remove all :on =>"changed" and i have the same problem <label><%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => "Choisissez votre Départements", :class => ''combo_chage''}%> <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => "Choisissez votre Ville", :class => ''combo_chage''}%> <% end %> <%= observe_field :pay_CodePays, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_zones, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_code_postaux, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> you can see problem here http://www.wexpay.com/pays_distributeurs bye --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Maybe if you would add a :url to your other observers? :-)my observers have all a :url I added the function in applications.js and remove all :on =>"changed" and i have the same problem <label><%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => "Choisissez votre Départements", :class => ''combo_chage''}%> <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => "Choisissez votre Ville", :class => ''combo_chage''}%> <% end %> <%= observe_field :pay_CodePays, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_zones, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_code_postaux, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> you can see problem here http://www.wexpay.com/pays_distributeurs bye --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Maybe if you would add a :url to your other observers? :-)my observers have all a :url I added the function in applications.js and remove all :on =>"changed" and i have the same problem <label><%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => "Choisissez votre Départements", :class => ''combo_chage''}%> <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => "Choisissez votre Ville", :class => ''combo_chage''}%> <% end %> <%= observe_field :pay_CodePays, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_zones, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> <%= observe_field :pay_code_postaux, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> you can see problem here http://www.wexpay.com/pays_distributeurs bye --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 14 Nov 2007, at 15:49, Bolo wrote:> my observers have all a :url > > > I added the function in applications.js and remove all :on =>"changed" > and i have the same problem > > <label><%= select :pay, > :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , > {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> > <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, > c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => > "Choisissez votre Départements", :class => ''combo_chage''}%> > <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, > c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => > "Choisissez votre Ville", :class => ''combo_chage''}%> > <% end %> > <%= observe_field :pay_CodePays, > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > %> > > <%= observe_field :pay_zones, > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > %> > > <%= observe_field :pay_code_postaux, > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > %> > > you can see problem hereThe problem you''re experiencing is because you replace your selects via ajax, while the observers are still bound to the old ones. The easiest way to solve this problem is by putting the selects in a span or div tag with an id, render them as partials with the observers in the partial: <div id="first_select><%= render :partial => "first_select" -%></div> _first_select.rhtml <%= select :pay, :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => "Choisissez votre Départements", :class => ''combo_chage''}%> <%= observe_field :pay_CodePays, :url => sort_pays_distributeurs_path, :with => "''_method=put&tag=''+element.id+''&value=''+element.value" %> Then do a replace_html of the first_select div. I don''t know why you''re using <label> here either, it''s not semantically correct. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Peter, it''s work now On 14 nov, 11:43, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> On 14 Nov 2007, at 15:49, Bolo wrote: > > > > > my observers have all a :url > > > I added the function in applications.js and remove all :on =>"changed" > > and i have the same problem > > > <label><%= select :pay, > > :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , > > {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> > > <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, > > c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => > > "Choisissez votre Départements", :class => ''combo_chage''}%> > > <%= select :pay, :code_postaux , @oVilles.collect {|c| [ c.Ville, > > c.id ] },{:prompt => @sous_region},{:selected => nil, :prompt => > > "Choisissez votre Ville", :class => ''combo_chage''}%> > > <% end %> > > <%= observe_field :pay_CodePays, > > :url => sort_pays_distributeurs_path, > > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > > %> > > > <%= observe_field :pay_zones, > > :url => sort_pays_distributeurs_path, > > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > > %> > > > <%= observe_field :pay_code_postaux, > > :url => sort_pays_distributeurs_path, > > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > > %> > > > you can see problem here > > The problem you''re experiencing is because you replace your selects > via ajax, while the observers are still bound to the old ones. > > The easiest way to solve this problem is by putting the selects in a > span or div tag with an id, render them as partials with the > observers in the partial: > > <div id="first_select><%= render :partial => "first_select" -%></div> > > _first_select.rhtml > <%= select :pay, > :CodePays , @oPays.collect {|c| [ c.LibelleFr, c.id ] } , > {:selected => nil , :prompt => "Choisissez votre Pays"}%></label> > <%= select :pay, :zones , @oZones.collect {|c| [ c.LibelleFr, > c.id ] } ,{:prompt => @region}, { :selected => nil, :prompt => > "Choisissez votre Départements", :class => ''combo_chage''}%> > <%= observe_field :pay_CodePays, > :url => sort_pays_distributeurs_path, > :with => "''_method=put&tag=''+element.id+''&value=''+element.value" > %> > > Then do a replace_html of the first_select div. > > I don''t know why you''re using <label> here either, it''s not > semantically correct. > > Best regards > > Peter De Berdt--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---