0

您好我开发了一个在一个文件中有 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();
                }
            })
        });
//  });       
}
4

1 回答 1

0

pagebeforeload只需添加代码以在page2 事件中隐藏/显示您的列表视图费用,如下所示:

$('#page2').bind('pagebeforeload',function(event){
   if (expenses_paid) { //use your own logic here
      //hide list view
   } else {
      //show expenses list view
   }
});
于 2012-10-02T13:30:09.023 回答