jQuery UI可排序事件多次触发

时间:2013-01-10 10:35:04

标签: jquery jquery-ui jquery-ui-sortable

我正在使用一个项目,它基于jQuery UI Sortable和Draggable。 问题是多次触发可排序事件。 (我用过搜索)。

有JS:

$('.column_inner').sortable({
    item: '.element',
    revert: 'invalid',
    helper: 'original',
    handle: '.drag_handle',
    dropOnEmpty: true,
    forcePlaceholderSize: true,
    forceHelperSize: false,
    appendTo: "body",
    connectWith: '.column_inner',
    receive: function(event, ui) {
        //Got the item and if it new inserting it from database.
    },
    update: function(event, ui) {
        //Saving sorting in to database
    },
    change: function(event, ui)
    {
        //This one fires multiple times, over does the same.
    },
    stop: function()
    {
        //This one fires only at stop
    }
});

有HTML:

<div class="row" id="row_115">
    <div class="column size_3" rel="1">
        <div class="column_inner">
            <div id="element_23" class="element editable">
                This is element
                <span class="drag_handle control_icon">Handle</span>
            </div>
            </div>
        </div>
    </div>
    <div class="clear"></div>
    <span class="up">UP</span> <span class="down">DOWN</span>
</div>

<div class="row" id="row_117">
    <div class="column size_half" rel="1">
        <div class="column_inner">
            <div id="element_20" class="element editable">
                Another element<br />
                <span class="drag_handle control_icon">Handle</span>
            </div>
        </div>
    </div>
    <div class="column size_half" rel="2">
        <div class="column_inner">
            <div id="element_20" class="element editable">
                Third element<br />
                <span class="drag_handle control_icon">Handle</span>
            </div>
        </div>
    </div>
    <div class="clear"></div>
    <span class="up">UP</span> <span class="down">DOWN</span>
</div>

我做错了什么?为什么事件多次发生?

0 个答案:

没有答案