一部のページ遷移で、ページ変更ハンドラーがアプリ内で 2 回起動するという問題があります。deviceready ハンドラで:
$(document).bind("pagechange", onPageChange);
次に、ハンドラ:
var onPageChange = function (event, data) {
var fromPageId = null;
//Get the ID of the page we are transitioning to.
var toPageId = data.toPage.attr("id");
//Get the ID of the page we are coming from.
if (data.options.fromPage) {
fromPageId = data.options.fromPage.attr("id");
}
console.log("pagechange to " + toPageId + " from " + fromPageId);
switch (toPageId){
...
}
}
アプリがあるページから次のページに遷移するとき、onPageChange が 2 回起動していることを LogCat で確認できます。
01-26 18:49:50.490: I/Web Console(18244): pagechange to care-plan-view from care-plan-view:25
01-26 18:49:50.490: I/Web Console(18244): pagechange to care-plan-view from care-plans:25
これはログに表示される順序です。奇妙なことに、ケア プラン ビューが宛先ページで、ケア プランが開始ページです。
これは、ページ遷移の問題を引き起こすサンプル リンクです。
<a data-role="button" data-icon="arrow-r" data-iconpos="right" href="#care-plan-view?id=9e273f31-2672-47fd-9baa-6c35f093a800&name=Sat"><h3>Sat</h3></a>
なぜこれが起こるのでしょうか?
乾杯、ドン