1
我在我的項目中使用了typeahead,但只適用於名稱。我無法處理進入自動填充的特定label
的ID。select bootstrap自動完成的標識和標籤
引導typeahead-
<input type="text" name="names" value="" id="typeahead" data-provide="typeahead" />
腳本 -
<script type="text/javascript">
$(function() {
$('#typeahead').typeahead({
source: function (term, process) {
var url = '@Url.Content("~/Invoice/GetNames")';
return $.getJSON(url, { term: term }, function (data) {
return process(data);
});
}
});
})
</script>
Json的方法 -
[HttpGet]
public JsonResult GetNames(string term)
{
var names = (from u in db.Contacts
where u.name.Contains(term)
select u).ToArray();
var results = names.Select(u => u.name);
return new JsonResult()
{
Data = results,
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
我在比賽中選擇整個表格行。但是,如何獲得帶有標籤名稱的Id
。
或 -
我可以選擇在服務器端整行,但問題仍然存在爲標籤和名稱過濾結果。