我有一份JSON的选取列表 我抓住了:
new SelectListItem
{
Text = item.Name,
Value = item.Id.ToString(),
Selected = item.Id.Equals(userId)
}).ToList();
此列表与 JQuery 的下拉菜单连接 :
$.Ajax call for an object above goes here...
function (data) {
data= $.map(data, function (item, a) {
return "<option value=" + item.Value + ">" + item.Text + "</option>";
});
$("#edit-user-list").html(data.join(""));
This works and populates my list just fine. I can t figure out syntax how to indicate my SELECTED item though! Can you guys help me out ? How with this JQuery can I indicate the selected item that s indicated in the passed in JSON collection of items?
谢谢