如何使用Jquery UI可选择查找所选元素 [英] how to find selected elements with Jquery UI selectable

查看:87
本文介绍了如何使用Jquery UI可选择查找所选元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找关于事件和ui对象的jQuery可选事件的信息:选择和开始作为参数。我在文档中找不到这个并且通过属性循环没有帮助。

I am looking for info on the event and ui objects the jQuery selectable events: "selecting", and "start" take as parameters. I cannot find this in the documentation and looping through the properties is no help.

$('#content_td_account').selectable({
    filter: 'li:not(".non_draggable")',
    selecting: function(event, ui) { 
    }
});

具体来说,我想找到被选中的元素并检查它们以查看它们的父元素是否为相同与否。我假设这将在ui对象的某些地方。

Specifically I want to find what elements are being selected and check them to see if their parent elements are the same or not. I assumed this would be in the ui object some where.

推荐答案

当选择一个元素时,它会获得 ui-selected 类添加。

When an element is selected it gets the ui-selected class added.

所以你可以用 $(。ui-selected)获得所有选中的元素

这可能不完全正常,但我认为这个想法是这样的:

This might not work exactly but I think the idea would be something like this:

$('#content_td_account').selectable({
  filter: 'li:not(".non_draggable")',
  selecting: function(event, ui) { 
    var p = $(this).parent();
    $(".ui-selected").each(obj, function() {
      if(obj.parent() == p) {
        // get rad
      }
    });
  }
});

这篇关于如何使用Jquery UI可选择查找所选元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆