function GenericSelectFirst(e) {
$("#LocationEdit_ddlSiteCode").data("kendoDropDownList").value(siteValue);
$("#LocationEdit_ddlSiteCode").data("kendoDropDownList").trigger('change'); // This line throws the javascript error
}

<select id="LocationEdit_ddlSiteCode" class="full-width"
data-bind="source: DataSource.SiteCodeDropDown, value: ViewModel.SiteCode, events:{dataBound: Function.GenericSelectFirst, change:Function.GenerateLocationCode}"
data-role="dropdownlist"
data-value-primitive="true"
data-value-field="Code"
data-text-field="Code"
>
</select>
&#13;
我有一个简单的kendo下拉列表,在其DataBound事件中,我试图设置值并触发它的更改事件。
但是,触发器代码在Chrome控制台中提供n is not a function
,我做错了什么以及如何修复它?
答案 0 :(得分:0)
经过数十年的谷歌搜索,调试和测试,我终于通过将绑定代码放入
来使其运行 $( document ).ready(function() {}
然后将kendo.bind()放入setTimeout函数中:
setTimeout(function(){ kendo.bind("#view", viewModel); }, 0.0001);
如果您卡住以使其运行而没有抛出错误,则“ n不是函数”,我认为此解决方案将有所帮助。如果我能弄清楚为什么会发生,我会在稍后更新我的答案。