-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Schedule has an infinite loop on the event. #2264
Comments
I made a quick edit, it's not infinitely looping in all cases. |
I'm unable to replicate; <button type="button" (click)="add($event)">Add</button>
<p-schedule [events]="events" [header]="header" defaultDate="2017-02-01" [eventLimit]="4" [editable]="true" (onViewRender)="testMethod($event)"></p-schedule> ngOnInit() {
this.eventService.getEvents().then(events => {this.events = events;});
}
testMethod(e) {
console.log('View');
}
add() {
this.events.push({
"id": 13,
"title": "Click for Google",
"url": "http://google.com/",
"start": "2017-02-25"
});
} When I click the add button it adds the event to the schedule and then changing view or date does not result in loop. Please provide a test case and we'll reopen. |
Hi, The problem seems to be from setting the onViewRender event. If you need to reset your current event list it will go on an infinite loop. Is there another way to do this? Here is a plunker to reproduce: http://plnkr.co/edit/2WMrT6euFd8WWzciKBrZ |
I have modified the way I reset the events and the infinite loop is gone: http://plnkr.co/edit/rbJxyvAU3Sxw4BHpiZwA |
Can confirm this behavior. Replacing the events list triggers another onViewRender event, causing infinite loop. |
@1guru Trying to access your plunker and its stuck on Loading? Weird. Can you post here how you prevented the infinite loop? |
@jacqueslareau instead of reinitializing the events array, I have removed the elements from it: export class AppComponent {
events: any[]=[];
loadEvents(event) {
console.log(event);
this.events.splice(0, this.events.length);
this.events.push({
start: "2017-03-20",
end: "2017-03-21",
});
}
} |
I've replicated |
I'm submitting a ... (check one with "x")
Plunkr Case (Bug Reports)
I am unable to reproduce this on a Plunkr as your Plunkr does not include FullCalendar and jQuery (needed dependencies for this issue).
Current behavior
On the latest version of PrimeNG (including the latest FullCalendar plugin), the (onViewRender) event loops constantly (edit ONLY when events are added to the schedule through the [events] attribute).
However, if I manually go into node_modules/primeng/schedule/ from the previous version and replace the entire contents of schedule.js, it returns to normal functionality and begins working.
There were obviously a lot of changes made to the schedule.js file (diff brings up ~250 adds/removes), so I suspect it has something to do with the new FullCalendar version OR the wrappers you've provided for it.
Expected behavior
The (onViewRender) event should only be called when the date changes or an action has taken place. In all previous versions this would be called when:
A: The component was being initialized.
B: The date was changed (either through methods or using the built-in interface).
Minimal reproduction of the problem with instructions
Put a <p-schedule (onViewRender)="testMethod($event)"> on your template. Add a method such as this to your component:
testMethod(e)
{
console.log(e);
}
You'll see that the method is called infinitely.
Please tell us about your environment:
OSX Sierra, 2016 MBP, Angular-CLI (latest version), Atom, VM running through Vagrant for backend.
Angular version: 2.4.5
PrimeNG version: 2.0.1
Browser: Chrome
Language: TypeScript 2.1.5
Node (for AoT issues): 6.9.4
The text was updated successfully, but these errors were encountered: