2013-08-30 63 views
0

我使用的劍道UI移動滾動條,但不知何故即時得到一個錯誤試圖調用scrollviewermoveTo功能時劍道UI移動滾輪錯誤

Cannot call method 'moveTo' of undefined 

我敢肯定,我已經在kendo.mobile.all.js引用(我使用Icenium劍道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> 

回答

0

嘗試修改代碼以使該行:

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

採取的形式:

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

,看看有沒有幫助。