2

嘿,我正在尝试在弹出窗口中获取可重新排序的列表。重新排序的演示代码在我的主要内容区域中工作得很好,但在弹出窗口中却不行。

它正确构建列表项和按钮,但是当您触摸重新排序按钮时,它会引发此错误

Uncaught TypeError: Cannot read property 'getValues' of null
ReorderDrag._moveElement @ ionic.bundle.js:7557
ReorderDrag.start @ ionic.bundle.js:7586
ionic.views.ListView.ionic.views.View.inherit._startDrag @ ionic.bundle.js:7872
ionic.views.ListView.ionic.views.View.inherit._handleDrag @ ionic.bundle.js:7932
(anonymous function) @ ionic.bundle.js:7738
triggerEvent @ ionic.bundle.js:811
dragGesture @ ionic.bundle.js:1860
detect @ ionic.bundle.js:1389
bindDomOnTouch @ ionic.bundle.js:938

将此代码(从文档页面粘贴的副本)放在选项卡的 ion-content 标记中时,它可以正常工作。

<![CDATA[ // Actual code on following lines

<ion-list show-reorder="true">
  <ion-item ng-repeat="item in items">
    Item 
    <ion-reorder-button class="ion-navicon"
                        on-reorder="moveItem(item, $fromIndex, $toIndex)">
    </ion-reorder-button>
  </ion-item>
</ion-list>

]]>

但是,当放置相同的代码时,此处使用的模板

$scope.popupReorder = function() {
     var popup = $scope.activePopup = $ionicPopup.alert({
       title: 'Reorder Layers ',
       templateUrl: 'templates/tab-mix-reorder.html',
       okType: 'button',
       okText: 'close',
       scope: $scope
     });
   };

列表正确呈现,但引发错误。

4

1 回答 1

3

对于任何未来的 googlers:发生错误是因为重新排序功能依赖于<ion-list>元素被包装在<ion-scroll>元素中。只需将弹出窗口中的列表包装在一个<ion-scroll>元素中,一切都会很好地工作!

于 2017-01-25T17:39:17.917 回答