1

私はその理由を理解しようとしています

$('#title').replaceWith('ha'); 

外で働くでしょう

drop: function(event, ui) {}

jquery のドロップ可能なスクリプトの領域ですが、内部では機能しません。具体的には、

$(".droppable").droppable({
drop: function(event, ui) {
    $('#title').replaceWith('ha'); 
     }

を取得しRuntime Error (line 1102) data(...).options is null or not an objectます。$('#title').append('ha');また、drop: の中にa を挿入すると、機能します。しかし、私$('#title').replaceWith('ha');が外のどこかに置くと

$(".droppable").droppable({ /* */  });

できます?

4

2 に答える 2

7

これを回答として投稿していますが、実際にはJon Ericksonの回答に対するコメントです(コメントする評判ポイントはまだありません)。18 か月後、これはまだ IE のバグであり、setTimeout() を提案して、「ドロップ関数の外で何かを実行する方法」の部分について詳しく説明したかっただけです。

要素を削除する匿名関数を setTimeout() に渡すことで問題を解決しています。スナップまたは復帰の設定によっては、ドラッグ可能なものを非表示にすることも検討してください。

$(".droppable").droppable({
    drop: function(event, ui) {
        // do something interesting here...

        // now get rid of the draggable
        $(ui.draggable).hide();           
        setTimeout(function(){$(ui.draggable).remove();}, 1);
    }
});
于 2011-03-01T02:22:03.623 に答える