2012-02-18 7 views
2

こんにちはみんな私はアンドロイドのjqueryモバイル経由でドラッグアンドドロップのイベントに取り組んでいます。私はブラウザ上でコードをテストしたが、デバイス上ではうまく動作しなかった。誰でも私にこの問題を助けることができます。 1 - デバイスは、あなたが使用 2 - ファイルは「jqueryの携帯ではありませんインターネット接続を持つことがあります。私は、リンクの第一のチュートリアルを次のです....PhoneGap App - ドラッグアンドドロップでアンドロイド経由でjqueryモバイル

http://www.elated.com/articles/drag-and-drop-with-jquery-your-essential-guide/ 

答えて

0

ためにここにそれを投稿してください、あなたはそれが成功したブラウザ上で働いていたことを告げました。私は問題がおそらくあなたが使用したjqueryファイルだと思う。 Webサイトにあるjqueryファイルをリンクしていた場合、デバイスがインターネットに接続されていることを確認してください。インターネットに接続していない場合は、 "jquery mobile"ファイルをassest/wwwフォルダにダウンロードしてリンクしてください。

エミュレータでアプリケーションを実行しませんでしたか?あなたが直面したエラーは何ですか?

0

問題は、以下のいずれかになります。 " Webページの開発に使用されるjqueryファイルです。 3-タブレットでアプリケーションを使用する場合、アプリケーションはタブレットのマウスで動作すると思います。しかし、触れることによって動作することはできません。

これは私が推測できる問題です。あなたは正確な解決策を見つけることを願っています。そして、あなたはそれを見つけた場合、

<script type="text/javascript"> 
    $(document).ready(function() { 
    $(init); 
    function init() { 
    document.addEventListener("touchstart", touchHandler, true); 
    document.addEventListener("touchmove", touchHandler, true); 
    document.addEventListener("touchend", touchHandler, true); 
    document.addEventListener("touchcancel", touchHandler, true); 
    } 
    $(function(){ 
    $(".drag") 
    .bind("dragstart", function(event){ 
    // ref the "dragged" element, make a copy 
    var $drag = $(this), $proxy = $drag.clone(); 
    // modify the "dragged" source element 
    $drag.addClass("outline"); 
    // insert and return the "proxy" element  
    return $proxy.appendTo(document.body).addClass("ghost"); 
    }) 
    .bind("drag", function(event){ 
    // update the "proxy" element position 
    $(event.dragProxy).css({ 
    left: event.offsetX, 
    top: event.offsetY 
    }); 
    }) 
    .bind("dragend", function(event){ 
    // remove the "proxy" element 
$(event.dragProxy).fadeOut("normal", function(){ 
$(this).remove(); 
}); 
// if there is no drop AND the target was previously dropped 
if (!event.dropTarget && $(this).parent().is(".drop")){ 
// output details of the action 
$('#log').append('<div>Removed <b>'+ this.title +'</b> from <b>'+ 
    this.parentNode.title +'</b></div>'); 
// put it in it's original <div> 
$('#nodrop').append(this); 
    } 
// restore to a normal state 
    $(this).removeClass("outline"); 
    }); 
    $('.drop') 
.bind("dropstart", function(event){ 
// don't drop in itself 
if (this == event.dragTarget.parentNode) return false; 
// activate the "drop" target element 
$(this).addClass("active"); 
}) 
.bind("drop", function(event){ 
// if there was a drop, move some data... 
$(this).append(event.dragTarget); 
// output details of the action... 
$('#log').append('<div>Dropped <b>'+ event.dragTarget.title +'</b> into <b>'+ 
    this.title +'</b></div>'); 
}) 
.bind("dropend", function(event){ 
// deactivate the "drop" target element 
$(this).removeClass("active"); 
    }); 
}); 
    function touchHandler(event) 
    { 
    var touches = event.changedTouches, 
    first = touches[0], 
    type = ""; 
    switch(event.type) 
    { 
    case "touchstart": type = "mousedown"; break; 
    case "touchmove": type="mousemove"; break;   
    case "touchend": type="mouseup"; break; 
    default: return; 
    } 
    var simulatedEvent = document.createEvent("MouseEvent"); 
    simulatedEvent.initMouseEvent(type, true, true, window, 1, 
     first.screenX, first.screenY, 
      first.clientX, first.clientY, false, 
       false, false, false, 0/*left*/, null); 
    first.target.dispatchEvent(simulatedEvent); 
    event.preventDefault(); 
    return; 
    } 
    }); 
    </script> 
+0

Uは見たことがあるemrullah .... – user1051599

0

あなたのコードは正常に見える...これは私がEmrullahを行っている私のスクリプトである私:)

関連する問題