Forum: Ruby on Rails Retitled: Best way to customize <option> tags in Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2008-12-03 02:47
All,

(sorry, I mis-titled this post as "Best way to add custom onclick
handler to select options" and posted it before I could fix the title).

I want to make an individual <option> in a <select> act as an in-place
edit field.

I get how the in_place_editor works, and it appears if I simply place a
tag "around" the <option> of interest, and then mark this tag as the
edit-in-place target, I should be good.

The trick is how do I easily decorate the <option> tag with a <p> or
<span> tag?  By "decorate" I mean that the HTML output would be

<span id="edit_in_place"><option>...</option></span>

The standard select() and options_for_select() helpers only take
enumerations with ids and values, they don't allow for any customization
as to tags around the <option> tag.

It seems like I have two options:

1) Completely compose the options for my select "by hand."  Then I can
do whatever I want.

2) I could call "options_for_select" and then using some crazy regex,
modify the output text and decorate my option of interest that way.

Was curious if anyone had some clever suggestions and would be willing
to share them with me.

Thanks,
Wes
This topic is locked and can not be replied to.