views:

78

answers:

1

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 () {
    $(".test-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.

+1  A: 

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.

Graham