-
Notifications
You must be signed in to change notification settings - Fork 490
Issue when reloading data with two tables #282
Comments
Looks like the call to this.load = function() {
DTInstances.getLast().then(function(dtInstance) {
dtInstance.changeData(function() {
return $q(function(resolve) { resolve([{ a: 1 }, { a: 2 }, { a: 3 }]); });
});
});
}; It appears that each time ui-router changes state and re-renders the template, a new DTInstance is pushed onto DTInstances. I'm guessing this is not the desired behavior. |
Thank you! That was indeed the issue. I now understand what is happening. I'm not sure how getLast() decides when to resolve the promise, but it seems to happen as soon as any datatable is present in DTInstances - which is really the best a function with this name can do. That's why it works for the view loaded first but not for the second view. I think it is expected that a new instance is created when the template is re-rendered, because a new datatable directive is instantiated. What I an wondering though is: Why is the "old" instance still present? Shouldn't it be destructed if the DOM table gets unloaded? If that was happening I suppose getLast() would behave as expected. |
Yeah, it's not the desired behaviour. Thanks for noticing it 👍 |
Fixed. See the change in the modified plnkr. However, this fix is not really satisfactory. In order to fix this issue, I had to "revert" the enhancement #234 (possibility to call The reason for this fallback is because I don't know if |
Any workaround this? Same as the first guy, if you navigate to other view and then back to the first view the event ".on('click" for that cell stops happening.
|
In my application I encountered a very weird behavior. I have two views, each with one datatable. If only one of the views is accessed, no problem occurs. If you however navigate to the other view and then back to the first view (so the second table is instantiated), it is no longer possible to update any datatable.
What happens in this case is that the system tries to process the new rows with the columnDefs "data" function of the OTHER table respectively!
I was able to create a Plunker example of this behavior: http://plnkr.co/edit/ZvNyJV81i21tZhp4Bz9u
Steps to recreate:
I don't know if the error depends on it being two seperate views or if it would occurr as well if the tables are on the same page.
The text was updated successfully, but these errors were encountered: