views:

63

answers:

1

I have been trying to implement this jquery plugin to my app.I need help trying to output something like this

<select name="user[university_id]" id="user_university_id" class="selectable">
    <option value="1" title="uni1">Uni1</option>
    <option value="2" title="uni2">Uni2</option>
</select>

by using a rails helper...the problem is the helpers never seem to output a title attribute to the option tags.. which is critical for this plugin

please help, thanks in advance

Edit: my current rails code is

<%= f.collection_select(:university_id,University.all,:id,:name) %>

which simply outputs

<select name="user[university_id]" id="user_university_id">
        <option value="1">Uni1</option>
        <option value="2">Uni2</option>
    </select>

So basically what I need is a way to also add title attribute to my options.

+1  A: 

You could just add it with jQuery, if you don't go the rails helper route:

$(function () {

    $('select.selectable option').each(function () {
        $(this).attr('title', $(this).text());
    });

});
AndrewDotHay
But that defeats the purpose of using rails helpers... dont see the reason to do that but appreciate the jquery tip
NachoF