【发布时间】:2017-03-11 22:44:26
【问题描述】:
我正在使用https://github.com/ichord/At.js 库来实现自动完成。
但是当我使用 remoteFilter 时,它会显示“未定义”下拉列表,就像他们在 https://github.com/ichord/At.js/wiki/How-to-use-remoteFilter 中所说的那样。
型号:
public class CaseHistory
{
public int CaseHistoryId { get; set; }
[Display(Name = "Symptom/Disease")]
[Required(ErrorMessage = "Please enter symptom or disease")]
public string SymptomOrDisease { get; set; }
public string Description { get; set; }
}
API 操作代码:
private ApplicationDbContext db = new ApplicationDbContext();
// GET api/CaseHistories
public IQueryable<CaseHistory> GetCaseHistories()
{
return db.CaseHistories;
}
这是我在剃刀视图中的代码:
var myUrl = 'https://localhost:44301/api/CaseHistories';
$('#inputor').atwho({
at: ":",
callbacks: {
/*
It function is given, At.js will invoke it if local filter can not find any data
query [String] matched query
callback [Function] callback to render page.
*/
remoteFilter: function(query, callback) {
$.getJSON(myUrl, { q: query }, function (data) {
callback(data);
});
}
}
});
【问题讨论】:
-
请分享Api操作代码
-
@zaitsman 我已添加 Api 操作代码。
标签: javascript c# jquery at.js