0

我正在使用 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>
4

1 回答 1

0

尝试修改您的代码,以便该行:

var scroller = $("#myScroller").kendoMobileScroller();

采取以下形式:

var scroller = $("#myScroller").data("kendoMobileScroller");

看看这是否有帮助。

于 2014-05-28T09:58:03.833 回答