I'm working on web project in MVC 3 with Razor c#.
I have used @Html.DropDownListFor
that display item dynamically. I want to set tooltip for every item of @Html.DropDownListFor
.
My line of code as below
@Html.DropDownListFor(m => m.Type, new SelectList(Model.Types, "Value", "Text", Model.Type),
new { @class = "Type"})
I felt curious about this question so just tried to achieve it. I created a simple example and made it work to display different tooltip on each select item hover.
Note: I am not an expert in JS side and not sure if it is an ideal way.
Here is my example code:
MyController.cs
LoadCountries.cshtml
TooltipDefinition.js
I guess I am not doing anything different than what you attempted. I am capturing all select items and attaching title attribute when items are loaded. The tooltip text comes from JS file. You may well be able to pass it through Model.
Sharing as it may well suits your need.