Hello, After reading and reading the documentation, I can''t append some javascript function into a select. It''s not possible ? documentation: ------------------------------------------------------------- select(object, method, choices, options = {}, html_options = {}) some code: ------------------------------------------------------------- return select(:id, :year, [ [''2008'', 2008], [''2007'', 2007], [''2006'', 2006]], :selected => session[:user_year], :onChange => ''enterprise_function();'' ) what I want: ------------------------------------------------------------- <select name="year_popup" id="year_popup" onChange="year_function()"> <option value="2007" selected="selected">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> </select> -- 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 -~----------~----~----~----~------~----~------~--~---
On 2 Dec 2007, at 22:18, Raimon Fs wrote:> > some code: > ------------------------------------------------------------- > return select(:id, :year, [ [''2008'', 2008], > [''2007'', 2007], > [''2006'', 2006]], :selected => session[:user_year], :onChange > => > ''enterprise_function();'' ) > >I believe you want> select(:id, :year, [ [''2008'', 2008], > [''2007'', 2007], > [''2006'', 2006]], {:selected => > session[:user_year]}, :onChange => > ''enterprise_function();'' )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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> I believe you want > >> select(:id, :year, [ [''2008'', 2008], >> [''2007'', 2007], >> [''2006'', 2006]], {:selected => >> session[:user_year]}, :onChange => >> ''enterprise_function();'' )thanks, it works ... so, reading in the docs: ------------------------------------------------------------- select(object, method, choices, options = {}, html_options = {}) you put the onChange... between curly braces {} in the options, and what can we put in the html_options {} thanks ! raimon -- 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 -~----------~----~----~----~------~----~------~--~---
On Dec 3, 7:44 am, Raimon Fs <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > so, reading in the docs: > ------------------------------------------------------------- > select(object, method, choices, options = {}, html_options = {}) > > you put the onChange... between curly braces {} in the options, and what > can we put in the html_options {} >It''s the other way round. The first hash is options, which takes selected and a few other things. The second hash (html_options) goes straight out to the rendered html, so if you put ''foo'' => ''bar'' then your select tag would have foo="bar" as an attribute. 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Dec 3, 7:44 am, Raimon Fs <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> so, reading in the docs: >> ------------------------------------------------------------- >> select(object, method, choices, options = {}, html_options = {}) >> >> you put the onChange... between curly braces {} in the options, and what >> can we put in the html_options {} >> > > It''s the other way round. The first hash is options, which takes > selected and a few other things. The second hash (html_options) goes > straight out to the rendered html, so if you put ''foo'' => ''bar'' then > your select tag would have foo="bar" as an attribute. > > Fredok, now I understand ... thanks again! raimon -- 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 -~----------~----~----~----~------~----~------~--~---