Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(pagination): pageChanged emitted 3 times on init #76

Closed
piernik opened this issue Jan 13, 2016 · 10 comments
Closed

chore(pagination): pageChanged emitted 3 times on init #76

piernik opened this issue Jan 13, 2016 · 10 comments
Assignees

Comments

@piernik
Copy link

piernik commented Jan 13, 2016

I'm using Your pagination component and I can see that pageCahnged is emitted 3 times on component init - why?

@valorkin valorkin changed the title pageChanged emitted 3 times on init chore(pagination): pageChanged emitted 3 times on init Jan 13, 2016
@joehmchan
Copy link

I encountered the same issues. I worry my problem is caused by two way bindings, and it triggered pageChanged multiple times.

@valorkin
Copy link
Member

just to keep updated, I will update this to beta1, then modal, then system.js build, tests and then issues
most probably tomorrow :)

@valorkin
Copy link
Member

@piernik is it still reproducing on latest version? can not reproduce

@jhiemer
Copy link

jhiemer commented Jan 20, 2016

On my side the pageChanged event is not fired at all:

(page-changed)="pageChanged($event)" in the pagination and private pageChanged(event : any) : void { console.log('Page changed to: ' + event.page); console.log('Number items per page: ' + event.itemsPerPage); };

In my component. Something wrong with that?

@jhiemer
Copy link

jhiemer commented Jan 20, 2016

Ah documentation is wrong http://valor-software.github.io/ng2-bootstrap/index-bs4.html#pagination, where it is (page-changed).

@valorkin
Copy link
Member

pageChanged
very strange, I was updating gh-pages

@valorkin
Copy link
Member

thx! for some reason it was not updated,
need to automate this process
I will update later today

@joehmchan
Copy link

@valorkin I upgraded to latest version, still reproducing the issue.
My setup is like that, the pagination component is wrapped in a child component.
Everytime when pager / pagination item is clicked, this child component will be updated.

I tried to trace the pagination.ts, and saw that page change event fired 3+ times. 2 times caused by updating total field.

Is it a proper way to do so? Should I treat pagination as static component and not reloading when result set refreshed?

@EternallLight
Copy link

Hi,

I've faced the same issue with getting the pageChanged event for three times on init, which obviously caused by running the page setter. It runs for the first time on the component's init

this.page = this.cd.value;

...and for the rest two times from the writeValue, probably triggered by parent controller initialization.
In my case, pageChanged is even triggered for the 4th time, when I get the response and set the totalitems property.

Changing pages triggers the event for once only if I re-use the parent component. Otherwise, it would be reinitiated and emit pageChanged for 3 times over and over.

I'm gonna get by with an if statement in my code, but most certainly it should not be that sensible.

@AndrewLang
Copy link

I got this issue too, it cause multiple request to the server.

And if the pagination rebuild with the page data, for example navigate to page 5, the pagination will navigate to page 1 automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants