简体   繁体   English

使用Knockout Kendo全局设置选项

[英]Set options globally with Knockout Kendo

Following http://rniemeyer.github.io/knockout-kendo/web/AutoComplete.html I thought it would be a good idea to set many options globally. http://rniemeyer.github.io/knockout-kendo/web/AutoComplete.html之后,我认为在全球范围内设置许多选项是一个好主意。 So I also tried 所以我也试过

<input data-bind="kendoAutoComplete: {}" />

ko.bindingHandlers.kendoAutoComplete.options.data = "choices";
ko.bindingHandlers.kendoAutoComplete.options.value = "selectedChoice";

However, it does not work. 但是,它不起作用。 The input element is made into an AutoComplete, but no elements show up when typing. 输入元素被制成“自动完成”,但键入时没有任何元素显示。

Are there some options that must be set in the markup? 标记中是否必须设置一些选项? Or do I make some mistake and should all options be allowed in the global object? 还是我会犯一些错误,是否应该在全局对象中允许所有选项?

Answering my own question... 回答我自己的问题...

I misunderstood the options object. 我误解了选项对象。 I thought that I could define the names of the viewmodel properties there. 我以为可以在那里定义viewmodel属性的名称。 I now realized that I have to code the actual values instead. 现在,我意识到我必须对实际值进行编码。

I would have prefered if I would be able to globally define " the data is always read from the 'data' property of the view model ". 我希望能够全局定义“ 始终从视图模型的'data'属性读取数据 ”。 However, this is not the intended use case for the global options. 但是,这不是全局选项的预期用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM