ボタンがクリックされたときにグローバル属性を設定して、次のように $('html') に保存してみてください。
$('html'). attr('toggleIs',true);
次に、pagebforeshowでこれを確認し、ボタンの状態に応じて表示されるすべての新しいページのボタンにトグル状態を追加できます。
編集
これはjsfiddleです(最初のアラートは無視してください)。
html は次のとおりです。
$(document).on('change', '.your_select', function(){
// set
if( $(this).find('option:selected').val() == "on" ){
$('html').data('toggle', 'on');
} else {
$('html').data('toggle', 'off');
}
});
$(document).on('pagebeforeshow', '.ui-page', function(){
var that = $(this).find('.your_select');
// clear
that.find('option').removeAttr('selected');
// reset
if($('html').data('toggle') == "on" ){
alert("should be on")
that.find('select option[value="on"]').attr('selected', 'selected')
} else {
alert("should be off")
that.find('option[value="off"]').attr('selected', 'selected')
}
// refresh slider
...
});
ご注意ください:
- jquery 1.6.4 を使用している場所を確認するのに時間がかかったので、私の on-bindings が機能しませんでした。保持したい場合は、バインディングにliveを使用して、取り込まれているページもキャプチャする必要があります。
- すべてのスライダーにクラスを与えて、それらをまとめました
- スライダーまたは親要素でJQMスライダー(「更新」)を機能させることができません...自分でそれを理解する必要がありますが、同期は機能しています:-)