0

ボタンをクリックしてテキストから画像を作成し、その画像を親div要素のドラッグ可能なdivに追加するWebページがあります。divは更新パネルにあります。このイベントの後、divはドラッグ可能です。別の画像->テキストを追加すると、HTMLを一時的に保存し、その位置でdivを再作成する別のボタンがあります。ただし、このイベントの後、すべての古いdivはドラッグプロパティを失い、追加された最後のdivは引き続きドラッグ可能なプロパティを保持します。

 $(".inner").live('mousedown', function() {
    $(this).draggable({
              containment: "#<%=divMain.ClientID%>",
        cursor: "move",
        stop: function(event, ui) {
             var position = $(this).position();
            $(this).css("top", position.top + 'px');
            $(this).css("left",position.left + 'px');
        }
    });
});

これが私の現在の機能です。提案してください !これはFirefoxとChromeで完全に機能します。問題はIEでのみ発生します。

4

2 に答える 2

1

あなたの提案に感謝します、私は解決策を見つけました、私がajax [postback]を通して動的にdivを追加するとき、私は追加されたすべてのdivのdraggbleを破壊します。$('。draggable')。draggable('destroy'); 次に、ライブ関数$("。draggable'")。live(' mousedown click'、function(){...});を使用してドラッグ可能な関数を再割り当てします。完璧に動作します。

于 2011-02-18T05:49:29.183 に答える
0

これは、jqueryが部分的なポストバック後にイベントを失っているためです。このように使ってみてください、

function pageLoad() { $(".inner").live('mousedown', function() { $(this).draggable({ containment: "#<%=divMain.ClientID%>", cursor: "move", stop: function(event, ui) { var position = $(this).position(); $(this).css("top", position.top + 'px'); $(this).css("left",position.left + 'px'); } }); }); }

于 2011-02-12T11:06:27.277 に答える