考虑这里给出的基本示例:
- https://aurelia-ui-toolkits.github.io/demo-kendo/#/samples/slider-basic-use https://aurelia-ui-toolkits.github.io/demo-kendo/#/samples/slider-basic-use
...这也可以在 gist.run 上找到:
- https://gist.run/?id=387c43948dc83acf59ea3497472bdfe9 https://gist.run/?id=387c43948dc83acf59ea3497472bdfe9
In that app.html
,有几个滑块构造为input
of class="eqSlider"
, 像这样:
<input repeat.for="value of equalizerSliderValues"
ak-slider="k-orientation: vertical;
k-min.bind: -20;
k-max.bind: 20;
k-value.bind: value;
k-small-step.bind: 1;
k-large-step.bind: 20;
k-show-buttons.bind: false" class="eqSlider"/>
我想要的是我添加一个attached()
方法,并遍历类的所有这些滑块eqSlider
,通过打印出来console.log()
,并调用resize()
方法 (http://docs.telerik.com/kendo-ui/api/javascript/ui/slider#methods-resize http://docs.telerik.com/kendo-ui/api/javascript/ui/slider#methods-resize)在他们每个人身上。
... 在顶部app.js
in the gist.run
例如,但它失败了:
Failed to load resource: the server responded with a status of 404 (OK)
bluebird.min.js:29 Unhandled rejection Error: XHR error (404 OK) loading https://gist.host/run/1487343107475/jquery.js
at o (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js:4:12694)
at XMLHttpRequest.s.onreadystatechange (https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js:4:13219)
作为杰夫提议的替代方案,您还可以使用这个伎俩 https://gist.run/?id=67ed498e8103e86647466f85829a8d11.
基本上,您可以定义一个滑块数组,其中初始值widget
属性为空:
sliders = [{
value: 10,
widget: null
}, {
value: 20,
widget: null
}]
然后,使用迭代该数组repeat.for
,您可以绑定k-widget
to the widget
每个滑块的属性。
<input repeat.for="slider of sliders"
ak-slider="k-value.bind: slider.value;
k-widget.bind: slider.widget"/>
所有滑块都初始化后,您最终会得到一个滑块数组,其中widget
属性是 Kendo 控件实例。
通过使用.map
在此数组上使用函数,您可以获得所有 Kendo 滑块小部件的数组:var sliders = this.sliders.map(x => x.widget);
.
由于k-widget值不能在之后使用attached()
已被执行,如所解释的here https://aurelia-ui-toolkits.gitbooks.io/kendoui-bridge-docs/content/what_you_need_to_know.html#595-how-to-get-to-the-kendo-control,您可以使用 TaskQueue 来通过 Attached() 执行您想要执行的操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)