I have this select field:
<label for=''user_access''>Access</label>
<%= f.select :access, [''Global'',
''Carrier'', ''Winery''], :prompt =>
"Choose One" %>
being observed by:
<%= observe_field :user_access, :on => ''blur'',
                               :url => {:action
=> :find_access}, :frequency => 0.25,
                               :with => ''value'' %>
When the user selects an option like ''Carrier'' I''d
like an empty div
to be replaced with a partial of carrier names... I''m doing this with:
page.replace_html :user_options, :partial =>
''shipper_options'', :object => @shippers
in the find_access.rjs file. My problem is that if I have the select
list open and roll over ''Carrier'' it does the replace_html on
the
div... is there a way to make it wait until the user actually selects
the value ''Carrier''?
Thanks for any help... this is my first foray into AJAX and I know
this is probably a stupidly simple issue.
SH
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
shenry wrote:> I have this select field: > > <label for=''user_access''>Access</label> > <%= f.select :access, [''Global'', ''Carrier'', ''Winery''], :prompt => > "Choose One" %> > > being observed by: > > <%= observe_field :user_access, :on => ''blur'', > :url => {:action > => :find_access}, :frequency => 0.25, > :with => ''value'' %> > > When the user selects an option like ''Carrier'' I''d like an empty div > to be replaced with a partial of carrier names... I''m doing this with: > > page.replace_html :user_options, :partial => > ''shipper_options'', :object => @shippers > > in the find_access.rjs file. My problem is that if I have the select > list open and roll over ''Carrier'' it does the replace_html on the > div... is there a way to make it wait until the user actually selects > the value ''Carrier''? > > Thanks for any help... this is my first foray into AJAX and I know > this is probably a stupidly simple issue. > > SHThe seleced value transmitted to the server is the current value of your selectbox. Untill an option is not clicked it is not selected. I think a better event would be onchange instead of on blur, to trigger your ajax query. Like that no need to observe the field all the time, so i''ts better for the app. -- 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 -~----------~----~----~----~------~----~------~--~---
I''ve changed the select field to be:
<%= f.select :access, [''Global'',
''Carrier'', ''Winery''], :prompt =>
"Choose One",
                     :onchange => remote_function(:url => {:action
=> :find_access}) %>
nothing happens when changing the selection (I don''t see the onchange
in the html source either...)
Should I be coding the javascript manually, rather than using helpers?
thx
SH
On Jul 13, 10:07 pm, nico Itkin
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> shenry wrote:
> > I have this select field:
>
> > <label for=''user_access''>Access</label>
> > <%= f.select :access, [''Global'',
''Carrier'', ''Winery''], :prompt =>
> > "Choose One" %>
>
> > being observed by:
>
> > <%= observe_field :user_access, :on => ''blur'',
> >                                :url => {:action
> > => :find_access}, :frequency => 0.25,
> >                                :with => ''value''
%>
>
> > When the user selects an option like ''Carrier''
I''d like an empty div
> > to be replaced with a partial of carrier names... I''m doing
this with:
>
> > page.replace_html :user_options, :partial =>
> > ''shipper_options'', :object => @shippers
>
> > in the find_access.rjs file. My problem is that if I have the select
> > list open and roll over ''Carrier'' it does the
replace_html on the
> > div... is there a way to make it wait until the user actually selects
> > the value ''Carrier''?
>
> > Thanks for any help... this is my first foray into AJAX and I know
> > this is probably a stupidly simple issue.
>
> > SH
>
> The seleced value transmitted to the server is the current value of your
> selectbox. Untill an option is not clicked it is not selected.
>
> I think a better event would be onchange instead of on blur, to trigger
> your ajax query. Like that no need to observe the field all the time, so
> i''ts better for the app.
> --
> Posted viahttp://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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
D''oh... here is what works =>
<%= f.select 	:access, [''Global'',
''Carrier'', ''Winery''], {:prompt =>
"Choose One"},
			:onchange => remote_function(:url => {:action => :find_access},
			:with => "''value='' + value") %>
wasn''t paying attention to the curly braces.
thanks nico,
SH
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---