こんにちは、1 つのファイルに 5 つの HTML ページを持つモバイル アプリを開発しています。
ページ 2 には、建物の経費のリストビューがあります。
ページ 3 には、ページ 2 で選択した費用を支払うための関数があります。上記の関数の最後に、以下のコードを含めます。
$.mobile.changePage('#page2', 'slideup', true, true);
アプリが3ページから2ページに戻ったときに、支払い済みの費用を表示しないようにしたい。
2ページ目のページ更新やリストビューの更新をよく理解しているかどうか知りたいです。
changepage コマンドで reloadPage を追加しようとしましたが、うまくいきませんでした。
これどうやってするの?
リストビューを作成するために使用する関数は次のとおりです
function getItemPayments(buildingcode) {
var list = $('#recentflatsPayments'),
items = [];
$.mobile.notesdb.transaction(function(t) {
t.executeSql('SELECT DISTINCT buildingaddress, buildingcode FROM expense WHERE buildingcode = ?',[buildingcode], function(t, resultbuilding) {
var myrow;
myrow = resultbuilding.rows.item(0);
$('#displayPayments h2').text(myrow.buildingaddress);
});
});
$.mobile.notesdb.transaction(function(t) {
t.executeSql('SELECT barcode, buildingcode, buildingaddress, description, entryseason, period, amount FROM expense WHERE buildingcode = ?',[buildingcode], function(t, resultexpense) {
var i,
len = resultexpense.rows.length,
myrowpaidlen = 0,
myrowpaid = 0,
row;
if (len > 0 ) {
for (i = 0; i < len; i += 1) {
dummypaid(i);
}
function dummypaid(i){
var row = resultexpense.rows.item(i);
t.executeSql('SELECT * FROM expensepayments WHERE Barcode = ?',
[row.barcode],
function(t, resultpaid) {
var myrowpaidlen = resultpaid.rows.length;
if (myrowpaidlen > 0){
var myrowpaid = resultpaid.rows.item(0);
if (row.amount > myrowpaid.Amount){
items.push('<li><a href="#displayexpense" data-description="' + row.description + '" data-buildingcode = "' + row.buildingcode + '" data-barcode="' + row.barcode + '" data-amount="' + row.amount + '" data-buildingaddress="' + row.buildingaddress + '">' + row.description + '</a></li>');
}
} else {
items.push('<li><a href="#displayexpense" data-description="' + row.description + '" data-buildingcode = "' + row.buildingcode + '" data-barcode="' + row.barcode + '" data-amount="' + row.amount + '" data-buildingaddress="' + row.buildingaddress + '">' + row.description + '</a></li>');
}
if (i+1 == len){
items.push('<li><a href="#displayexpense" data-description="other" data-buildingcode = "' + row.buildingcode + '" data-barcode="0" data-amount="0" data-buildingaddress="' + row.buildingaddress + '">Other</a></li>');
}
list.html(items.join('\n'));
list.listview('refresh');
$('a', list).click(function(e) {
getItem1Payments($(this).attr('data-description'), $(this).attr('data-buildingcode'), $(this).attr('data-barcode'), $(this).attr('data-amount'), $(this).attr('data-buildingaddress'));
});
$('#entriesflatPayments').show();
});
}
} else {
$('#entriesflatPayments').hide();
}
})
});
// });
}