2012-10-02 117 views
0

嗨我开发了一个文件中有5个html页面的移动应用程序。如何在更改页面后刷新列表视图

在页面2我有建筑物费用的一览表。

在3页I,以便从第2页 支付所选费用在上述函数的末尾有一个函数I包括下面的代码

$.mobile.changePage('#page2', 'slideup', true, true); 

我想,当应用程序返回到页2页第3页不显示付费。

我想如果我很好地理解页面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(); 
       } 
      }) 
     }); 
// });  
} 

回答

0

只需添加代码隐藏/显示在pagebeforeload事件的Page2你的ListView的费用,这样的功能:

$('#page2').bind('pagebeforeload',function(event){ 
    if (expenses_paid) { //use your own logic here 
     //hide list view 
    } else { 
     //show expenses list view 
    } 
}); 
+0

我想显示所有费用(列表视图)免除已付费用 – kosbou

+0

同样的代码适用,只需使用您的逻辑来查找您的付费费用并将其从列表视图中隐藏。如果你想要一个具体的代码示例,你必须粘贴你的页面代码。 – Nelson

+0

我有一个名为getitemspayment的函数,其中buildingcode作为创建未付费用列表视图的val。如何从changepage或pagebeforeload调用它 – kosbou