开发者

jQuery UI Draggable 'stop' event called too many times?

I have a feeling I'm either misunderstanding the 'stop' event or not doing it right, but it seems to be called several times while the element is bound to is being dragged.

makeAllDragable = function () {
    $(".tes开发者_运维知识库t-table").draggable({
        start: function (event, ui) { $(this).click(); },
        stop: function (event, ui) { foo() }
    }).click(function () {
        selectTable($(this));
    });
}

foo = function () {
    alert("test");
}

In this example foo is called about 30 times, shouldn't is just be when I release the draggable? The jQuery docs don't actually say one where or another though.


As it turns out, the above code I wrote up in my original question was not what i was working with, I actually had foo() called like so:

makeAllDragable = function () {
    $(".test-table").draggable({
        start: function (event, ui) { $(this).click(); },
        stop: function (event, ui) { foo() }
    }).click(function () {
        foo(); /*difference here*/
    });
}

For whatever reason dragging it raises the click() function repeatedly when the function is also present in the stop() event. At least that's what appears to be happening on the surface at least.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜