Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui jquery DragAndDrop安装程序无法正常工作_Jquery Ui_Jquery Ui Draggable - Fatal编程技术网

Jquery ui jquery DragAndDrop安装程序无法正常工作

Jquery ui jquery DragAndDrop安装程序无法正常工作,jquery-ui,jquery-ui-draggable,Jquery Ui,Jquery Ui Draggable,我构建了一个树状视图,呈现如下(此处仅显示第一个li,其余类似): 我需要帮助的问题是:如何使选择器更具体,以便能够拖动到每个“.cas”节点。在我当前的情况下,每当我拖动任何内容时,它都会附加到列表中的顶级“.cas”元素,例如,对于数据id=930的li的子ul中的每个li,我将930作为数据id,而不是当前节点的数据id值 我使用的jquery插件是jquery-ui-1.8.16.custom.js 提前感谢,, 西尔维乌 L.E.:如您所见,我尝试了多种方法来获取所需的id,但都指向顶

我构建了一个树状视图,呈现如下(此处仅显示第一个li,其余类似):

我需要帮助的问题是:如何使选择器更具体,以便能够拖动到每个“.cas”节点。在我当前的情况下,每当我拖动任何内容时,它都会附加到列表中的顶级“.cas”元素,例如,对于数据id=930的li的子ul中的每个li,我将930作为数据id,而不是当前节点的数据id值

我使用的jquery插件是jquery-ui-1.8.16.custom.js

提前感谢,, 西尔维乌

L.E.:如您所见,我尝试了多种方法来获取所需的id,但都指向顶级的“.cas”li元素


L.L.E:我还必须提到,这些类并没有向元素添加任何样式,它们只是作为选择器存在的。

好吧……考验已经结束,亲爱的各位!!!在构建树时,我更改了
数据id
数据类型后缀
HTML属性的位置,因此它们现在被放置在
元素中,而不是其父元素
  • 元素中

    在js部分,我只需要:

    accept: '.cas',
    drop: function (event, ui) {
                        var changeParentRequest =
                        {
                            ID_CAS: $(ui.draggable).data('id'),
                            IDCASPARENT_CAS: $(this).data('id')
                        };
                        $.postAntiForgery(
                            GetURL('Stock/UpdateCasierParent'),
                            changeParentRequest,
                            loadTreeView
                        );
                    }
    
    对于.csm和.material类也是如此。对我来说很好,我说:)

    干杯,快乐编码,ppl


    西尔维乌

    什么都没有?我仍在努力解决这个问题,但仍然卡住了…所以也许有人会再看看这个。。。
    $('#stockTreeView').on('stockLoad', function () {
        $('.cas').droppable(
            {
                accept: '.materiel',
                drop: function (event, ui) {
    
                    var addRequest =
                    {
                        ID_MAT: $('#Materiel').data('tGrid').dataItem($(ui.draggable).closest('tr')).ID_MAT,
                        ID_CAS: $(this).closest("li").data('id')
                    };
                    console.log(addRequest);
                    addMaterielWindowManager.LoadWindowContent('Stock/AddMateriel', addRequest, 'Ajouter materiel');
                }
            }
        ).droppable(
            {
                accept: '.cas',
                drop: function (event, ui) {
                    var changeParentRequest =
                    {
                        ID_CAS: $(ui.draggable).parent().data('id'),
                        IDCASPARENT_CAS: $(this).parent().data('id')
                    };
                    console.log(changeParentRequest);
                    $.post(
                        GetURL('Stock/UpdateCasierParent'),
                        changeParentRequest,
                        loadTreeView
                    );
                }
            }
        ).droppable(
            {
                accept: '.csm',
                drop: function (event, ui) {
                    var changeParentRequest =
                    {
                        ID_CSM: $(ui.draggable).data('id'),
                        IDCAS_CSM: $(this).data('id')
                    };
                    console.log(changeParentRequest);
                    $.post(
                        GetURL('Stock/UpdateCasierMateriel'),
                        changeParentRequest,
                        loadTreeView
                    );
                }
            }
        );
    
        $('.cas, .csm').draggable(
            {
                helper: 'clone',
                appendTo: 'body',
                revert: 'invalid'
            }
        );
    
    });
    
    accept: '.cas',
    drop: function (event, ui) {
                        var changeParentRequest =
                        {
                            ID_CAS: $(ui.draggable).data('id'),
                            IDCASPARENT_CAS: $(this).data('id')
                        };
                        $.postAntiForgery(
                            GetURL('Stock/UpdateCasierParent'),
                            changeParentRequest,
                            loadTreeView
                        );
                    }