Hi, How do I assign an id to my select tags generated by the date helper like select_month and select_time, etc? Thanks, Sam -- 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 -~----------~----~----~----~------~----~------~--~---
Sam Woodard wrote:> Hi, > > How do I assign an id to my select tags generated by the date helper > like select_month and select_time, etc? > > Thanks, > SamSam, this sounded like an easy thing to look up, but having looked, there doesn''t seem to be a direct way to set it. It seems to me that you might be able to work your way around it with something like this (untried), which is just setting a string to the result of the helper, and then inserting the usual id="foo" type thing into the string before outputting that to the html... <% my_select = select_month %> <%= my_select.gsub(/select /,"select id=''foo'' " %> This is just a guess. Give it a try and let us know if this is a workable solution. Note the lack of an = on the first line, it shouldn''t create any output into the html stream. The second line does have an =, so it should take the result of the gsub and "publish it" to the html page. best, jp -- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 28, 2006, at 7:51 PM, Jeff Pritchard wrote:> > Sam Woodard wrote: >> Hi, >> >> How do I assign an id to my select tags generated by the date helper >> like select_month and select_time, etc? >> >> Thanks, >> Sam > > Sam, this sounded like an easy thing to look up, but having looked, > there doesn''t seem to be a direct way to set it. > > It seems to me that you might be able to work your way around it with > something like this (untried), which is just setting a string to the > result of the helper, and then inserting the usual id="foo" type thing > into the string before outputting that to the html... > > <% my_select = select_month %> > <%= my_select.gsub(/select /,"select id=''foo'' " %> > > This is just a guess. Give it a try and let us know if this is a > workable solution. Note the lack of an = on the first line, it > shouldn''t create any output into the html stream. The second line > does > have an =, so it should take the result of the gsub and "publish > it" to > the html page. > > best, > jpYeah it''s kinda lame that the date_select helper does nt allow you to assign your own id''s or classes. I gt around it by using some JS to add class names to the date selects. So you can put this in your view below the date_select call: <script type="text/javascript" > $$(''select'').each(function(el) { if(el.className == ""){ el.addClassName("date-required"); }; }); </script> Maybe that points you in the right direction. -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This did it. Thank you so much. Sam Jeff Pritchard wrote:> It seems to me that you might be able to work your way around it with > something like this (untried), which is just setting a string to the > result of the helper, and then inserting the usual id="foo" type thing > into the string before outputting that to the html... > > <% my_select = select_month %> > <%= my_select.gsub(/select /,"select id=''foo'' " %> > > This is just a guess. Give it a try and let us know if this is a > workable solution. Note the lack of an = on the first line, it > shouldn''t create any output into the html stream. The second line does > have an =, so it should take the result of the gsub and "publish it" to > the html page. > > best, > jp-- 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 -~----------~----~----~----~------~----~------~--~---