I am using jQuery Chosen plugin in my ASP.NET MVC application. The data-placeholder
attribute is not working when the dropdownlist has items in it. Instead of showing default text it automatically selects the first item in the list.
This is how I define my dropdownlist.
@Html.DropDownListFor(m => m.Keep, Model.Data,
new { @class = "chzn-select", data_placeholder = "Default..." })
If Model.Data is empty (it is filled in view model using EF), then default text is displayed. Otherwise, the first item is selected. I always want my dropdownlist to show default value.
I apply the plugin via $('.chzn-select').chosen();
Nothing special.
Any ideas ? Thanks in advance.
Best Answer
You need to add an empty option first.
as per documentation - http://harvesthq.github.com/chosen/
Maybe use jQuery to add it