2016-10-21 6 views
2

昨日私のコードjQuery Mobileにロードされました。私はちょうど新しいjQueryのをテストするためにjavascript.jsを(最後のスクリプト)に次のコードを入れてjQueryのスワイプイベントはjQuery 3で動作しません

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.js" type="application/javascript"></script> 

<script>window.jQuery || document.write('<script src="../js/jquery-3.0.0.min.js" type="application/javascript"><\/script>')</script> 

<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script> 

<script type="application/javascript" src="../js/javascript.js" ></script> 

:以下は私のスクリプト設定(すべてのスクリプトが右終了タグの前にロードされている)でしたモバイルで動作しませんでした。

JAVASCRIPT/jQueryの

$j("body").on("swiperight", function(){ 
$j("#sidePanel").css("display","none"); 
}); 

この時点で、私はいくつかのデバッグを行なったし、問題はjQueryの3であることがわかりました。以前のバージョンのjQuery(2または1)をロードすると、問題は発生しません。魔法のように、次の作品:

<script src="https://code.jquery.com/jquery-2.2.4.js" integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" crossorigin="anonymous" type="application/javascript"></script> 

<script>window.jQuery || document.write('<script src="../js/jquery-2.2.4.js" type="application/javascript"><\/script>')</script> 

<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script> 

<script type="application/javascript" src="../js/javascript.js" ></script> 

質問:なぜスワイプイベントは、jQueryの3で動作しないのでしょうか?

ありがとうございます。

+0

なぜjquery 3を使用するのですか? – Mahi

答えて

2

jQueryモバイルには「jQuery 1.8 - 1.11/2.1」が必要です。現時点ではjQuery 3のサポートはありません。

回避策としてjQuery Migrate Pluginを使用できます。

<script src="https://code.jquery.com/jquery-3.0.0.js"></script> 
<script src="https://code.jquery.com/jquery-migrate-3.0.0.js"></script> 
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script> 
<script type="application/javascript" src="../js/javascript.js" ></script> 
関連する問題