简体   繁体   English

简单的JavaScript NestedSortableWidget(拖放)onchange不起作用

[英]Simple javascript NestedSortableWidget (drag&drop) onchange doesn't work

I use NestedSortableWidget . 我使用NestedSortableWidget I use this scripts: 我使用以下脚本:

<script type="text/javascript" src="../../Scripts/jquery-1.js"></script> 
<script type="text/javascript" src="../../Scripts/interface-1.js"></script>
<script type="text/javascript" src="../../Scripts/inestedsortable.js"></script>

and

<script type="text/javascript">
        jQuery(function($) {
            $('#spans-divs-regular').Sortable(
    {
        accept: 'page-item4',
        opacity: 0.8,
        helperclass: 'helper',
        onChange: function(serialized) {
        $('#left-to-right-ser').html("sds:" + serialized[0].hash);
        }       
    }
);
        });
</script>

I doesn't need nested items but sortable. 我不需要嵌套项目,但可以排序。 I only need to send postback to save items' state. 我只需要发送回发来保存项目的状态。 So when I use $('#spans-divs-regular').Sortable onchange doesn't work. 所以当我使用$('#spans-divs-regular').Sortable onchange不起作用。 But if use $('#spans-divs-regular').NestedSortable onchange works only when I change nesting elements. 但是如果使用$('#spans-divs-regular').NestedSortable onchange仅在我更改嵌套元素时有效。

Here is my simple html page: source_html . 这是我的简单html页面: source_html I need your help. 我需要你的帮助。

Solution

I solved this problem a long time ago. 我很久以前解决了这个问题。 So I don't remember the solution very well. 因此,我不太清楚该解决方案。 But I found my final script: 但是我找到了我的最终脚本:

<script type="text/javascript">
        jQuery(function($) {
            $('#spans-divs-regular').Sortable(
            {
                accept: 'page-item4',
                opacity: 0.8,
                helperclass: 'helper',
                onChange: function(serialized) {                  
                     $.post('/Persons/PersonViewOrderList?sort', serialized[0].hash + '');
                },
                autoScroll: true,
                handle: '.sort-handle',
                fx:300,
                revert: true
            })
        });
    </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM