在表

时间:2018-04-03 02:18:17

标签: jquery firebase firebase-realtime-database html-table

我正在研究一个类项目,并希望在将新记录推送到数据库时在表中显示最后5个firebase记录。这在我的页面加载时正常工作,但随着更多记录的添加,表格继续增大,直到我刷新页面。有什么建议?谢谢!

          productDatabase.ref().limitToLast(4).on("child_added", function(childsnapshot){

          //Grabs key from childsnapshot and sets it to variable
          var key = childsnapshot.key;

          //Store everything in variables from the "child" data
          var product = childsnapshot.val().ProductName;
          var datestamp = childsnapshot.val().DateAdded;


        //Uploading the results to the HTML table
        $("#producttable > tbody").prepend("<tr><td>" + product + "</td><td>");

0 个答案:

没有答案