Id tag assignment with date helper class

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 W. 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,
jp

On Oct 28, 2006, at 7:51 PM, Jeff P. wrote:

Sam, this sounded like an easy thing to look up, but having looked,
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

Yeah 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:

Maybe that points you in the right direction.

– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

This did it. Thank you so much.

Sam

Jeff P. 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