Cayce Balara
2006-Sep-14 13:27 UTC
AJAX Observe Form - problem with event handlers with :on
I have the following: <%= observe_form "picker_form",:frequency => 1, :update => "frame_picker" , :loading_text => "Retrieving price...", :complete => visual_effect(:highlight, "picker_live_price", { :startcolor => "''#9b3801''", :endcolor => "''#f0c18e''", :duration => 0.5 }), :url => { :controller => ''store'', :action => "update_picker" } %> It works as expected, the result is that a form is redrawn to dynamically populate drop-down lists. There is one problem - the AJAX update triggers if the user just hovers over a new value in a drop-down. The drop-down then disappears as the form is redrawn. I want the AJAX to fire only when the user clicks on an option, not for a hover. I''ve tried adding :on => "blur" to the observe_form call but it doesn''t seem to make a difference. I appreciate any help. I''m redrawing the entire form on the AJAX call - my next step is to change to redrawing individual select dropdowns, but that is a lot more code and it would appear from the api documentation that if I can find the right event for the :on => ? that I can get it working the way I want. thanks. c. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sergey Kuznetsov
2006-Sep-14 14:04 UTC
Re: AJAX Observe Form - problem with event handlers with :on
Remove :frequency statement. In that case that will be event driven. Cayce Balara wrote:> I have the following: > > <%= observe_form "picker_form",:frequency => 1, > :update => "frame_picker" , > :loading_text => "Retrieving price...", > :complete => visual_effect(:highlight, > "picker_live_price", { :startcolor => "''#9b3801''", :endcolor => > "''#f0c18e''", :duration => 0.5 }), > :url => { :controller => ''store'', > :action => "update_picker" } %> > > > It works as expected, the result is that a form is redrawn to > dynamically populate drop-down lists. There is one problem - the AJAX > update triggers if the user just hovers over a new value in a drop-down. > The drop-down then disappears as the form is redrawn. > > I want the AJAX to fire only when the user clicks on an option, not for > a hover. I''ve tried adding :on => "blur" to the observe_form call but it > doesn''t seem to make a difference. > > I appreciate any help. I''m redrawing the entire form on the AJAX call - > my next step is to change to redrawing individual select dropdowns, but > that is a lot more code and it would appear from the api documentation > that if I can find the right event for the :on => ? that I can get it > working the way I want. > > thanks. > c. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Cayce Balara
2006-Sep-14 17:20 UTC
Re: AJAX Observe Form - problem with event handlers with :on
Aw crud on a stick - can it really be that simple? Could it really have been right in front of me as I stared at the api docs? :frequency: The frequency (in seconds) at which changes to this field will be detected. Not setting this option at all or to a value equal to or less than zero will use event based observation instead of time based observation. Yes. Yes. Thanks so much Sergey. :) c. Sergey Kuznetsov wrote:> Remove :frequency statement. > In that case that will be event driven.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sergey Kuznetsov
2006-Sep-14 17:48 UTC
Re: AJAX Observe Form - problem with event handlers with :on
Cayce Balara wrote:> Aw crud on a stick - can it really be that simple? Could it really have > been right in front of me as I stared at the api docs? > > :frequency: The frequency (in seconds) at which changes to this field > will be detected. Not setting this option at all or to a value equal to > or less than zero will use event based observation instead of time based > observation. >I was hit the same brick time ago =) As an old geek I always like to see the actual code that''s how I realized about it. Even if that was on front of me in documentation =) Please note that it won''t work with radio buttons. Stop! Probably it may if you will provide id name only on the last <input type=radiobutton> element! In that case you can safely update any DOM elements via observe_(field|form ) with :complete field and I don''t have to use remote_function which is doesn''t work properly with IE on radiobuttons. Cool! I have to check it.> Yes. Yes. > > Thanks so much Sergey. :) >You are very welcome!> c. > > > Sergey Kuznetsov wrote: > >> Remove :frequency statement. >> In that case that will be event driven. >> > > >All the Best! Sergey. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Cayce Balara
2006-Sep-14 18:19 UTC
Re: AJAX Observe Form - problem with event handlers with :on
I also see that the RJS templates seem to trump the method I''m using in a major way. I just grabbed the O''Reilly RJS Templates for Rails booklet and it looks to be a gold mine. c. Sergey Kuznetsov wrote:> Cayce Balara wrote: >> Aw crud on a stick - can it really be that simple? Could it really have >> been right in front of me as I stared at the api docs? >> >> :frequency: The frequency (in seconds) at which changes to this field >> will be detected. Not setting this option at all or to a value equal to >> or less than zero will use event based observation instead of time based >> observation. >> > I was hit the same brick time ago =) As an old geek I always like to see > the actual code that''s how I realized > about it. Even if that was on front of me in documentation =) > > > Please note that it won''t work with radio buttons. Stop! Probably it may > if you will provide id name only on the last > <input type=radiobutton> element! In that case you can safely update any > DOM elements > via observe_(field|form ) with :complete field and I don''t have to use > remote_function which is doesn''t work properly > with IE on radiobuttons. Cool! > I have to check it. > >> Yes. Yes. >> >> Thanks so much Sergey. :) >> > You are very welcome! >> > All the Best! > Sergey.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sergey Kuznetsov
2006-Sep-14 18:52 UTC
Re: AJAX Observe Form - problem with event handlers with :on
Cayce Balara wrote:> I also see that the RJS templates seem to trump the method I''m using in > a major way. I just grabbed the O''Reilly RJS Templates for Rails booklet > and it looks to be a gold mine. > > c. >It looks like I will get my copy of that book soon =)))> > Sergey Kuznetsov wrote: > >> Cayce Balara wrote: >> >>> Aw crud on a stick - can it really be that simple? Could it really have >>> been right in front of me as I stared at the api docs? >>> >>> :frequency: The frequency (in seconds) at which changes to this field >>> will be detected. Not setting this option at all or to a value equal to >>> or less than zero will use event based observation instead of time based >>> observation. >>> >>> >> I was hit the same brick time ago =) As an old geek I always like to see >> the actual code that''s how I realized >> about it. Even if that was on front of me in documentation =) >> >> >> Please note that it won''t work with radio buttons. Stop! Probably it may >> if you will provide id name only on the last >> <input type=radiobutton> element! In that case you can safely update any >> DOM elements >> via observe_(field|form ) with :complete field and I don''t have to use >> remote_function which is doesn''t work properly >> with IE on radiobuttons. Cool! >> I have to check it. >> >> >>> Yes. Yes. >>> >>> Thanks so much Sergey. :) >>> >>> >> You are very welcome! >> >>> >>> >> All the Best! >> Sergey. >> > > >All the Best! Sergey. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fernando Poblete
2007-Jun-22 03:20 UTC
Re: AJAX Observe Form - problem with event handlers with :on
Hello, I have a similar proble with the :on property I have the following code in the view <%= start_form_tag :id => ''AjaxForm'' %> <%= text_field_tag :text1 %> <%= text_field_tag :text2 %> <%= observe_field :text1, :url => {:action => ''test''}, :update => ''ajaxWrapper'', :with => ''text1'', :on => ''blur'' %> <%= end_form_tag %> <div id=''ajaxWrapper''></div> The method ''test'' is def test render :text => ''hello world'' end The thing is that the observer doesn''t trigger on blur and it does trigger onchange (which is the default) even if I set it to :on => ''blur''. The same happens with ''click'', ''focus'', and any other event that I try. If someone knows something about it , please let me know. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2007-Jun-22 11:29 UTC
Re: AJAX Observe Form - problem with event handlers with :on
On Jun 21, 2007, at 11:20 PM, Fernando Poblete wrote:> Hello, I have a similar proble with the :on property > I have the following code in the view > > <%= start_form_tag :id => ''AjaxForm'' %> > <%= text_field_tag :text1 %> > <%= text_field_tag :text2 %> > <%= observe_field :text1, > :url => {:action => ''test''}, > :update => ''ajaxWrapper'', > :with => ''text1'', > :on => ''blur'' %> > <%= end_form_tag %> > > <div id=''ajaxWrapper''></div> > > The method ''test'' is > def test > render :text => ''hello world'' > end > > The thing is that the observer doesn''t trigger on blur and it does > trigger onchange (which is the default) even if I set it to :on => > ''blur''. > The same happens with ''click'', ''focus'', and any other event that I > try. > > If someone knows something about it , please let me know. > > ThanksIf you dive down into the source code, you find that the only :on value that has support at the JavaScript level is ''change'' and that it is very specific. A few months ago I had to track down some unexpected behavior (or more accurately the lack of expected behavior) and discovered this. That was with Rails 1.1.6, but I think it''s true at least as recently as 1.2.2 -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 -~----------~----~----~----~------~----~------~--~---