Pull to Refresh not working



  • I am trying to refresh my list of items using <q-pull-to-refresh> but when I pull the page down, it does not stop loading even though I have set the setTimeout to 1000. I want to refresh my list of items such that newly added items can be reflected in the list when refreshed. Is there any way I can solve this?

    Code:

    refresher (done) {
       setTimeout(() => {
         console.log("Refresh")
       }, 1000)
     } 
    


  • You have to call the “done” function.

    refresher (done) {
       setTimeout(() => {
         console.log("Refresh")
         done()
       }, 1000)
     } 
    


  • This post is deleted!


  • @ouaR Thank you for your reply! 🙂

    I would like to ask if there is a way I could reflect newly added items into the list when the page is pulled to refresh?
    I tried including my method getReminder() in the code but it does not work.

    I have a form that allows inputs into the database, and I am looking for a method to update the list of items (through pull to refresh) when new items are added.

    Code

    refresh (done) {
            setTimeout(() => {
              console.log("Refresh"),
              this.getReminder(),
              done()
            }, 1000)
          }
    


  • @felice said in Pull to Refresh not working:

    getReminder()

    Can you show the code for getReminder()? done() should be called when It’s when It’s finished running



  • @jadedRepublic here is the code for getReminder():

    methods: {
       getReminder() {     
               var documentClient = new AWS.DynamoDB.DocumentClient({apiVersion: "2012-08-10"});
               var params = {
                 TableName: "schedule",
                 Select: "ALL_ATTRIBUTES"
               };
               if(this.credentials) {
                 documentClient.scan(params, (err, data) => {
                 if (err) {
                   console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
                 } 
                 else {
                   for(var i in data) {
                     scanResults.push([i, data[i]]);
                   }
                   reminderData = scanResults[0];
                   reminderData = reminderData[1];
                   reminderData.forEach((item) => {
                   let med_id = item.medicine_id;
                   let med_name = item.medicine_name;  
                   let med_frequency = item.medicine_frequency;
                   let med_prescription = item.doctor_prescription;
                   let med_time = item.medicine_time;
                   this.tableData.push({id: med_id, 
                                            name: med_name, 
                                            frequency: med_frequency,
                                            prescription: med_prescription, 
                                            time: med_time});
              });
            }
         });
       }
       else {
               var that = this;
               var promise = AWS.config.credentials.getPromise();
               promise.then(() => {
                   var creds = {
                        ...
                   };
         
                   that.credentials = creds;
                   documentClient.scan(params, (err, data) => {
                   if (err) {
                     console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
                   } 
                   else {
                     for(var i in data) {
                     scanResults.push([i, data[i]]);
                   }
                   reminderData = scanResults[0];
                   reminderData = reminderData[1];
                   reminderData.forEach((item) => {
                      let med_id = item.medicine_id;
                      let med_name = item.medicine_name;  
                      let med_frequency = item.medicine_frequency;
                      let med_prescription = item.doctor_prescription;
                      let med_time = item.medicine_time;
                      this.tableData.push({id: med_id, 
                                              name: med_name, 
                                              frequency: med_frequency, 
                                              prescription: med_prescription, 
                                              time: med_time});
           });
         }
        });
       },
        function(err) {
               that.credentials = null;
            }
          );
      }
    

Log in to reply