capiono capiono - 1 year ago 136
ASP.NET (C#) Question

Select2 -- placeholder not displaying

I'm using Select2 Plugin in my mvc 5 application. according to the documentation

The placeholder option allows you to pass in a data object instead of just a string if you need more flexibility. The id of the data object should match the value of the placeholder option.

I have done exactly that, but the placeholder is still not showing up.


model.Step6.Titles.Insert(0, new SelectListItem() { Text = "Select a Title", Value = "0", Selected = true });

@Html.DropDownListFor(model => model.Step6.Title, Model.Step6.Titles, new { id="teamtitle", @style = "width: 100%;"})

allowClear: true,
placeholder: {
id: "0",
placeholder: "Select an Title"

can someone show me what I'm doing wrong here?

Answer Source

I think placeholder is a string. Not an object

    allowClear: true,
    placeholder:"Select an Title"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download