2

「バインド」関数で jQuery UI のドラッグ可能なオプションを使用するにはどうすればよいですか? 標準draggable()機能を使用しても、やりたいことがうまくいきません。

ありがとう!

$('a#dragthis')
    .bind('dragstart', function(e) {
        isDragging = true;
    })
    .bind('drag', function(e) {
        var x = e.pageX;
        var y = e.pageY;
        console.log(x + "|" + y);
        motivationIsWorking(x, y);
    })
    .bind('dragend', function(e) {
        isDragging = false;
        motivationStopped();
        unmotivateUser();
    });
4

1 に答える 1

2

Draggable には、探していることを正確に実行するためのコールバック関数があります。

http://jqueryui.com/draggable/

http://api.jqueryui.com/draggable/#event-stop

だからこれの代わりに

.bind('dragend', function(e) {
    isDragging = false;
    motivationStopped();
    unmotivateUser();
});

これを行う

$(element).draggable({
    stop:function( event, ui ) {
        isDragging = false;
        motivationStart();
        remotivateUser();
    }
});
于 2012-12-09T03:12:01.197 に答える