-
Notifications
You must be signed in to change notification settings - Fork 19
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
Error occurs when binding if a DOM element is removed before tinyMCE has been initialized #23
Comments
I'm running into this same issue because I am loading data from ajax. So my observable is initialized with ko.observable(new Post());, then the ajax call loads up real data and populates it a bit later and it's before tinymce is fully initialized. I'm not sure how to get around this, so I'm open to any suggestions :) |
After stepping through this today, the issue actually seems to be something a bit different. It's not that the binding is getting disposed, it's that it's calling init twice for some reason. The second time through is causing the issues. I stepped through other binding that I've written and this isn't the behavior, so I'm a bit stumped. I'm not sure exactly WHY it's getting called twice... |
I figured this out I think, here's a fiddle So what's happening is that the update after the binding is happening before the binding is complete. This causes the underlying value to be updated underneath it from what I can tell. This causes it to get confused and trigger the dispose call, and then do updates back and forth between the original value and the new value. stepping through it makes my brain hurt. But I don't think this is an issue with the binding as much as an issue with knockoutjs. If you comment out the bottom line with the setTimeout and use the other one you will see the issue. The one with the timeout gives the bindings enough time to finish then updates and doesn't cause this issue... |
Ok, so here's the fix. The issue is that the update is being done in the wrong place. comment out this line in the init function and add the update to the update so it looks like this, mind you I've edited mine so it's a bit different, but the else statement is the key. `
` I think you will find that this issue is resolved. This was not an easy one to figure out, in fact I didn't, the guys in the knockoutjs forum helped me with it... |
Thank you jlaustill, your fix is working perfectly! |
I have a page that makes part of its view not visible immediately. This is causing the DOM Node to be disposed. Because this happens so quickly, it sometimes occurs before tinyMCE is initialized. When this happens, the following error occurs:
Unhandled exception at line 41, column 5 in
https://localhost:44302/Scripts/lib/wysiwyg.js
0x800a138f - JavaScript runtime error: Unable to get property 'remove' of
undefined or null reference.
To continue development, I've been able to resolve this by assigning tinymce to a variable that I then check for null before calling the remove method:
Ultimately, I would expect this would still leak memory whenever it is unable to call the remove method. It would be nice to ensure that the tinymce has finished and then still go ahead and properly dispose it in this case.
The text was updated successfully, but these errors were encountered: