angular ui-sortable:在Firefox中停止点击事件

aw0*_*w04 1 firefox angularjs angular-ui-sortable

我正在使用角度ui-sortable通过拖放来订购商品.正在排序的项目也附加了一个点击事件.在firefox中,丢弃其中一个项会触发click事件.在我测试的所有其他浏览器中,它没有.

这是一个简单的例子(检查控制台日志):

HTML

<div ng-app="app" ng-controller="ctrl as vm">
  <div ui-sortable="vm.sortableOptions" ng-model="vm.items">
    <div ng-repeat="item in vm.items">
      <a href ng-click="vm.log()">
        <div class="box"></div>
      </a>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.box {
  width: 100px;
  height: 100px;
  background: #ff0000;
  margin: 8px;
}
Run Code Online (Sandbox Code Playgroud)

JS

angular.module('app', ['ui.sortable'])
    .controller('ctrl', [function () {
    var vm = this;

    vm.sortableOptions = {
        stop: function (e) {

      }
    }

    vm.items = [
        {},
        {},
        {},
        {}
    ];

    vm.log = function () {
        console.log('clicked');
    }
}]);
Run Code Online (Sandbox Code Playgroud)

我希望不会发生这种情况.调用Event.preventDefault()不会像我希望的那样工作(可能是因为它是一个角度点击事件).

我当然可以在停止回调中设置某种标志(它似乎总是在点击处理程序之前触发)但我更喜欢一个更清洁的解决方案,因为它可能会有点难以跟踪.

Der*_*lin 7

使用:

vm.sortableOptions = {
    helper: 'clone'
};
Run Code Online (Sandbox Code Playgroud)

它告诉模块使用克隆进行拖动,这也会禁用所有触发的事件.我检查了Firefox,它运行得很好.