問題を示す js フィドルを次に示します。
スワイプは赤いボックスでは正常に機能しますが、新しいボタンを押した後に作成される新しい青いボックスでは機能しません。(赤いボックスをマウスでスワイプして変更)
これがだまされている場合は申し訳ありませんが、特定の問題を解決する解決策がオンラインで見つかりませんでした.
コードは touchSwipe サイトからのものです
JavaScript
$(function() {
//Enable swiping...
$(".test").swipe( {
//Generic swipe handler for all directions
swipe:function(event, direction, distance, duration, fingerCount) {
$(this).text("You swiped " + direction );
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:0
});
});
$(document).on('click','button',function(){
$('<div class="test" id="test2">Swipe me</div>').appendTo('body');
});
HTML
<div class="test">Swipe me</div>
<button>New</button>