我正在使用 Kendo UI Mobile 滚动条,但在尝试调用scrollviewer
moveTo
函数时出现错误
Cannot call method 'moveTo' of undefined
我确定我引用了 kendo.mobile.all.js(我正在使用 Icenium Kendo UI 项目)
<div data-role="view" id="listview-headers" data-init="mobileListViewHeadersInit" data-title="Fixed Headers" data-model="viewModel" id="myView">
<a data-role="button" data-bind="click: scroll">Scroll to F</a>
<div data-role="scroller" style="height: 300px; margin: 0;" id="myScroller">
<ul id="fixed-listview"></ul>
</div>
</div>
<script>
$(function(){
var ViewModel = kendo.data.ObservableObject.extend({
scroll: function(e) {
console.log("scroll");
var pos = $("#M").position();
var scroller = $("#myScroller").kendoMobileScroller();
console.debug(scroller);
// this line below throws "Cannot call method 'moveTo' of undefined "
scroller.movable.moveTo({ x: pos.top, y: pos.left });
console.debug(pos);
}
});
$.extend(window, {
viewModel: new ViewModel(),
});
});
</script>