Skip to content

Refresh after new data added #269

@AO-IO

Description

@AO-IO

Hi.
thank you for the package. This package is the best so far for infinite scrolling !!!

I use vue-infinite-loading in my comments component.
usually before using vue-infinite-loading when I add a comment I call a fetch method to see the new data.

I'm using Laravel.

    getComments($state) {
      axios
        .get(`/comment/${this.post}/fetchMore?page=` + this.page)
        .then(
          function(response) {
            if (response.data.data.length) {
              this.page++;
              if (this.comments.length === 0) {
                this.comments = response.data.data;
                console.log("gotten page: " + this.page);
              } else {
                this.comments = this.comments.concat(response.data.data);
              }
              $state.loaded();
            } else {
              $state.complete();
            }
          }.bind(this)
        )
        .catch(function(error) {
          return "There was an error.";
        });
    }
<infinite-loading @distance="1" spinner="spiral" @infinite="getComments" ref="infiniteLoading">
    </infinite-loading>

How is it possible to fetch newly added comments?

I tried to reset the status in a method but that didn't work (i saw that in a StackOverflow question)

      if (this.$refs.infiniteLoading) {
        return this.$refs.infiniteLoading.stateChanger.reset();
      }

I can't figure this out. :\ thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions