フォーム付きの jQuery Mobile アプリケーションがあります。localStorage に格納されているフォームに誰かが入力すると、フォームには複数のフォーム要素があります。
1 つのフォームに入力した後、履歴ページで古いフォームを検索できます。誰かが古いフォームを開くと、localStorage 情報に従ってフォーム要素を入力する必要があります。最初のドロップダウンリストでこれを機能させましたが、ページにチェックボックスを追加すると、ドロップダウンボックスのみが更新されます。
私の JavaScript コード:
if (key !== "")
{
key = key.replace("?key=", "");
var string = localStorage.getItem(key);
var array = string.split(",");
$("#client option[value='" + array[0] + "']").attr("selected", "selected");
$("#location option[value='" + array[1] + "']").attr("selected", "selected");
$("#locationnumber option[value='" + array[2] + "']").attr("selected", "selected");
$("#turbine_id option[value='" + array[3] + "']").attr("selected", "selected");
$("#turbine_type option[value='" + array[4] + "']").attr("selected", "selected");
$("#turbine_brand option[value='" + array[5] + "']").attr("selected", "selected");
$('select').selectmenu('refresh'); //This is the refresh method
$('#check_maintenance').attr('checked', true);
$('#check_failure').attr('checked', false);
$('#check_inspection').attr('checked', true);
$('#check_warranty').attr('checked', false);
$('#check_assignment').attr('checked', true);
$('#check_reportedbyclient').attr('checked', false);
$('#check_management').attr('checked', true);
$('#check_restpoint').attr('checked', false);
$('#check_report').attr('checked', true);
$('input:checkbox').checkboxradio('refresh'); //This is the refresh method
}
1 つの関数で 2 つ以上の異なるフォーム要素を更新することはできないようです。他の誰かがこれを行うための正しい方法またはより良い方法を知っているかもしれません。
編集:
アンサーのオマールに感謝します。しかし、問題と思われるのは、選択メニューを更新すると、残りの機能が実行されないことです。
これは、いくつかのhtmlメニューを更新する方法です
$('select').selectmenu('refresh');
この行の下に置いたものはすべて実行されません。