TokenInput + Uncaught TypeError: Cannot read property 't
TokenInput + Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
我想创建一个文本框与预定义的可能值,但我最终得到一个错误:
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
我尝试使用令牌输入脚本(http://loopj.com/jquery-tokeninput/),但我未能从数据库读取数据。我正在使用。net MVC。
这是我的方法(在模型中)读取数据:
public List<CRMClientsModel> CRMClientsModel() {
var sqlConnect = DbConnectHelper.GetDbInstance<SqlConnection>();
var query = string.Format("SELECT CompanyName,Id from Company");
return sqlConnect.Query<CRMClientsModel>(query).ToList();
}
这里是控制器负责将数据转换为JSON格式的部分
CRMLogic Logic = new CRMLogic();
CRMModel Model = new CRMModel();
List<CRMClientsModel> Clients = Logic.CRMClientsModel().ToList();
List<CRMClientViewModel> ClientsVM = Clients.Select(a => a.ToViewModel<CRMClientViewModel>()).ToList();
Model.CRMClientsModel = Clients;
CRMViewModel ViewModel = new CRMViewModel();
ViewModel.CRMClientsModel = ClientsVM;
JavaScriptSerializer jsonSerialiser = new JavaScriptSerializer();
string json = jsonSerialiser.Serialize(ClientsVM);
ViewModel.jsonproject = json;
然后在View中被
调用<script type="text/javascript">
$(window).ready(function () {
@*var item = @Html.Raw(Model.jsonproject)
alert(item)*@
$("#inputproject").tokenInput(@Html.Raw(Model.jsonproject),
{
theme: "facebook", minChars: 0
});
});
</script>
明白了。原来这个错误是由于缺少"propertyToSearch"造成的。类似问题如下:jQuery-tokeninput failed: "未定义的吗?
相关文章:
- 未捕获TypeError: Cannot read property 'geocode'未定义的'
- SailsJs中的错误.TypeError: Cannot read property '的定义
- 未捕获的TypeError: Cannot read property 'top'的定义
- 未捕获的TypeError: Cannot read property '未定义的数据表
- 未捕获的TypeError: Cannot read property 'timing'的定义
- 未捕获的TypeError: Cannot read property 'checked'零
- 未捕获的TypeError: Cannot read property 'top'在引导中单击导航栏时未
- Extjs5 treepanel [Uncaught TypeError: Cannot read property &
- TypeError: Cannot read property 'submit'添加到购物车'
- 添加自定义jquery.验证方法导致Uncaught TypeError: Cannot read property &
- Vue 2和Vue- resource [Cannot read property 'get'未定义的(
- asp:textbox Uncaught TypeError: Cannot read property 'va
- TypeError: Cannot read property 'search' of undefine
- 读取json时出错未捕获类型错误:Cannot read property 'output'的定义
- 未捕获的TypeError: Cannot read property 'current'在选择任何选项
- 未捕获的TypeError: Cannot read property '3'的定义
- jquery-ui.js:12443未捕获的TypeError: Cannot read property 'a
- jquery Uncaught TypeError: Cannot read property 'left
- 未捕获类型错误:Cannot read property 'print'的定义
- TokenInput + Uncaught TypeError: Cannot read property 't