Here''s an example of the code I''m trying to get working... <%= collection_select(''book'', ''book_type_id'', all_book_types, ''id'', ''name'', :prompt => "Select Book Type...", :style => "width:200px" ) %> I''ve tried a bunch of different permutations but can''t get the style width to even appear in the html output. Putting the style hash in braces with or with the "html_options =" explicitly called out doesn''t help. I''ve Googled and looked at the API but can figure this one out. Any ideas? DAN -- 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2006-Dec-19 18:23 UTC
Re: How to do collection_select pulldown style="width:200px" ?
> Here''s an example of the code I''m trying to get working... > > <%= collection_select(''book'', ''book_type_id'', all_book_types, ''id'', > ''name'', :prompt => "Select Book Type...", :style => "width:200px" ) %> > > I''ve tried a bunch of different permutations but can''t get the style > width to even appear in the html output. Putting the style hash in > braces with or with the "html_options =" explicitly called out doesn''t > help. I''ve Googled and looked at the API but can figure this one out. > > Any ideas?What about this? <%= collection_select(''book'', ''book_type_id'', all_book_types, ''id'', ''name'', {:prompt => ''Select Book Type..."}, {:style => "width:200px"} ) The docs say that last two arguments are both hashes, so if you don''t encapsulate the :prompt with {}''s then I think ruby is going to consider *everything* from that point on to be part of options, not html_options... -philip --~--~---------~--~----~------------~-------~--~----~ 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''m wondering if I should try using something besides collection_select so the width style is rendered to html output. Any pointers greatly appreciated. Thanks, DAN -- 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 figured it out finally... ..., { :prompt => "Select Book Type..." }, { "style" => "width:200px" } This will set the width of a collection_select pulldown menu. Maybeposting the solution will help someone else if ever needed. DAN -- 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 -~----------~----~----~----~------~----~------~--~---
Makes sense. Thanks for the clarity! DAN -- 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 Bean
2009-Dec-30 02:18 UTC
Re: How to do collection_select pulldown style="width:200px"
DAN wrote:> I figured it out finally... > > ..., { :prompt => "Select Book Type..." }, { "style" => "width:200px" }I know this is old, but I''m bumping it because it helped me out. Also, one other tip for collection_select: If you don''t need the prompt, you can use this: …, {}, { "style" => "width:200px" } -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Marnen Laibow-Koser
2009-Dec-30 13:23 UTC
Re: How to do collection_select pulldown style="width:200px"
Rob Bean wrote:> DAN wrote: >> I figured it out finally... >> >> ..., { :prompt => "Select Book Type..." }, { "style" => "width:200px" } > > I know this is old, but I''m bumping it because it helped me out. Also, > one other tip for collection_select: > > If you don''t need the prompt, you can use this: > > …, {}, { "style" => "width:200px" }But note that none of these are good ideas. Style attributes do not belong in good HTML. Instead, use a separate CSS file. (For best results, add Sass and Compass into the mix.) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.