Forum: Ruby on Rails Best way to add custom onclick handler to select options

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2008-12-03 02:45

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.

This topic is locked and can not be replied to.