mharris717 / ember-cli-pagination

Pagination Addon for Ember CLI
MIT License
273 stars 116 forks source link

setOtherParam #244

Open vanness145 opened 6 years ago

vanness145 commented 6 years ago

image

setOtherParam will force the ember-cli-pagination to re-fetch current page.. However in my case, it would not work if I were to re-fetch the current page for the second time..

image

I looked into page-remote-array.js and found out that it doesnt run this.fetchContent() when setOtherParam was fired second time onwards because the lastPage was set to page..

Any idea hw to get this work? I need setOtherParam to re-fetchContent every time it was called..

broerse commented 6 years ago

Perhaps something like this will fix your problem.

  lastPage: null,
  lastParamsForBackendCounter: null,

  pageChanged: Ember.observer("page", "perPage", function() {
    var page = this.get('page');
    var lastPage = this.get('lastPage');
    var paramsForBackendCounter = this.get('paramsForBackendCounter');
    var lastParamsForBackendCounter = this.get('lastParamsForBackendCounter');
    if (lastPage != page || lastParamsForBackendCounter != paramsForBackendCounter) {
      this.set('lastPage', page);
      this.set('lastParamsForBackendCounter', paramsForBackendCounter);
      this.set("promise", this.fetchContent());
    }
  }),

I don't know what impact this would have. @alejandrodevs can you take a look while thinking about the remote redesign.

ppkpp commented 3 years ago

solved ? i faced the same problem on ember octane

broerse commented 3 years ago

@ppkpp I never implemented this code because I don't oversee what impact it would have on others. Do you think it would break something?