Hi there I''m observing a field (collection_select) but if the
collection only has one item, the observe field will not work, it
works for more than one item
here is my code
<%= collection_select ''address'',
''address'', @addresses, :id, :address %></p>
<%= observe_field(
              :address_address,
              :update => ''shipping'',
              :url => { :action => :shi },
              :on => "onselect",
              :complete => "new
Effect.SlideDown(''shipping'')",
              :with => ''boo'')  %>
I have tried a different of bunch :on => event
but no efect
any help would be very aprreciated
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi Jorge, Jorge Mario G. Mazo wrote:> Hi there I''m observing a field (collection_select) but if the > collection only has one item, the observe field will not workThat''s because, with only one item in the collection, there''s no event occurring. I think you''ll have to force the event by using a blank item, maybe with ''select one'' for the text at the beginning of the collection. Check the option_from_collection_for_select documentation. You may need to modify your approach a little. It says ''you have to wrap this call in a regular HTML select tag.'' Another option would be to render your UI differently depending on the number of items in the collection. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 Mar 13, 2007, at 12:31 AM, Jorge Mario G. Mazo wrote:> > Hi there I''m observing a field (collection_select) but if the > collection only has one item, the observe field will not work, it > works for more than one item > here is my code > <%= collection_select ''address'', ''address'', > @addresses, :id, :address %></p> > <%= observe_field( > :address_address, > :update => ''shipping'', > :url => { :action => :shi }, > :on => "onselect", > :complete => "new Effect.SlideDown(''shipping'')", > :with => ''boo'') %> > > I have tried a different of bunch :on => event > but no efect > any help would be very aprreciatedTo save you a dive down into the prototype.js library (since I was just there a week ago ;-), the only event that the underlying JavaScript supports is an implicit ''change'' or ''click'' depending on the element type (click for radio buttons and checkboxes, change for others). I spent several hours tracking down odd behavior which was partly explained by this. (The other part was having an autocomplete and and observe-field on the same form element -- nasty timing issues there!) -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---