【问题标题】:Angularjs: jquery selectable child element click issueAngularjs:jquery可选择的子元素点击问题
【发布时间】:2014-02-13 14:40:40
【问题描述】:

我已经使用 jquery selectable 来选择它的工作正常的元素。

myModule.directive('uiSelectable', function ($parse) {
    return {
        link: function (scope, element, attrs, ctrl) {

        scope.$on('clearselection', function (event, document) {
          element.find('.ui-selected').removeClass('ui-selected')
        });

            element.selectable({
                stop: function (evt, ui) {
                    var collection = scope.$eval(attrs.docArray)
                    var selected = element.find('div.parent.ui-selected').map(function () {
                        var idx = $(this).index();
                        return { document: collection[idx] }
                    }).get();

                    scope.selectedItems = selected;
                    scope.$apply()
                }
            });
        }
    }
});

问题是当我点击可选择的子元素时,它不会被点击,而是它的父元素点击(我已经实现可选择的地方)被触发

有人可以指导我如何使用 angularjs 点击子元素

Plunker

http://plnkr.co/edit/3cSef9h7MeYSM0cgYUIX?p=preview

经过一番研究,我得出结论是因为 Jquery UI-Selectable 任何人都知道如何使用 UI-Selectable 修复它,或者有任何其他替代方法来使用 ctlr + shift 选择多个项目

【问题讨论】:

  • 你能做类似$(selected).click()的事情吗
  • 我需要以角度方式进行。
  • 你已经在使用 jquery,$(this),那为什么呢?普通的 javascript 类似于selectable.onclick(),所以我不太明白角度方式的意义?
  • $(selected).click 我没明白你的意思你可以在 plunker 中编辑因为我觉得选择的是元素但我想要子元素点击
  • 很确定它与这篇文章有关。 stackoverflow.com/questions/5133966/…

标签: jquery angularjs jquery-ui-selectable


【解决方案1】:

添加距离:1 将解决您的问题。因为当您开始选择时,jQuery UI 在鼠标正下方添加一个元素(ui-selectable-helper)并阻止您单击“下方”元素。 http://plnkr.co/edit/WV9NmvwFX5ADYv5OUumF?p=preview

【讨论】:

    猜你喜欢
    • 2016-06-09
    • 1970-01-01
    • 2020-02-23
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多