【问题标题】:AngularJS/UI ui-sortable does not have isolated scope?AngularJS/UI ui-sortable 没有隔离范围?
【发布时间】:2013-07-07 17:21:50
【问题描述】:

当我在 ui-sortable 指令中查找 ng-repeats 时遇到的问题,后来我发现与此 (https://github.com/angular-ui/ui-sortable/issues/2) 的问题相同,我遇到了另一个关于ui-sortable 指令。

如果你看这个小提琴:http://jsfiddle.net/hKYWr/707/

请打开您的控制台,您会注意到,当您开始和停止拖动时,您会在控制台中看到“开始”和“停止”。

但是,当您引入具有不同选项的第二个 ui-sortable 部分时,它会覆盖第一个的事件(反之亦然)。您会注意到“停止”不再被第一组颜色调用:http://jsfiddle.net/hKYWr/708/

在单步执行 angular-ui.js 文件时,这些行会导致问题:

// If user provided 'start' callback compose it with onStart function
      _start = opts.start;
      opts.start = function(e, ui) {
        onStart(e, ui);
        if (typeof _start === "function")
          _start(e, ui);
      };

      // If user provided 'start' callback compose it with onStart function
      _stop = opts.stop;
      opts.stop = function(e, ui) {
        onStop(e, ui);
        if (typeof _stop === "function")
          _stop(e, ui);
      };

      // If user provided 'update' callback compose it with onUpdate function
      _update = opts.update;
      opts.update = function(e, ui) {
        onUpdate(e, ui);
        if (typeof _update === "function")
          _update(e, ui);
      };

_stop 似乎被最后调用的 ui-sortable 中的“未定义”覆盖。

有人如何处理同一页面上的多个 ui-sortable 元素吗?如果我做错了什么,请告诉我,提前谢谢!

【问题讨论】:

    标签: angularjs angularjs-directive jquery-ui-sortable angular-ui


    【解决方案1】:

    我刚刚将最新的sortable.js 代码复制并粘贴到jsfiddle 编辑器中,并删除了链接<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>。它似乎工作正常。

    请看演示。

    Demo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-23
      • 2019-10-21
      相关资源
      最近更新 更多