ページ変更を引き起こしたページのdata-urlを取得したいとします。何か案は?Jquery Mobile - pagebeforechangeイベントでdata-urlを取得する方法
$(document).bind("pagebeforechange", function (event , data) {
console.log(data.options.fromPage.attr('data-url'));
});
(注)document
に結合しているためという。
$(document).bind("pagebeforechange", function (event , data) {
// get the data-url of the link that triggered the page change
});
2回発射しますが、2回目にはtoPageはありません。現在のページが必要な場合は、いつでも行うことができます:$ .mobile.activePage.attr( 'data-url') –