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

Multiple instances of editor causes a console error #44

Closed
arch0njw opened this issue May 8, 2014 · 5 comments
Closed

Multiple instances of editor causes a console error #44

arch0njw opened this issue May 8, 2014 · 5 comments

Comments

@arch0njw
Copy link

arch0njw commented May 8, 2014

I have a use-case where I need to create multiple editors. When the second editor is created, the following console error is logged:

Uncaught TypeError: Cannot read property 'document' of null     wysihtml5x-toolbar-0.4.5.js:6712
getDocument                                                     wysihtml5x-toolbar-0.4.5.js:6712
wysihtml5.views.Composer.wysihtml5.views.View.extend._create    wysihtml5x-toolbar-0.4.5.js:11514
sandbox.dom.Sandbox.stylesheets                                 wysihtml5x-toolbar-0.4.5.js:11489
(anonymous function)                                            wysihtml5x-toolbar-0.4.5.js:6746
@arch0njw
Copy link
Author

arch0njw commented May 8, 2014

This looks like it can be resolved with the following edits:

wysihtml5x-toolbar.js
~line 6711
change

  this.getWindow = function() { return iframe.contentWindow; };
  this.getDocument = function() { return iframe.contentWindow.document; };

to

  this.getWindow = function() { return iframeWindow; };
  this.getDocument = function() { return iframeDocument; };

@arch0njw
Copy link
Author

arch0njw commented May 8, 2014

Nix that. That leads to another issue.

I think I've refined the problem down to dynamically adding a new wysihtml5 editor to the dom. It doesn't seem to know how to resolve what the iframe.contentWindow is when that happens.

@pulges
Copy link
Contributor

pulges commented May 9, 2014

Can you give some more details about browser/os and how are you implementing the two editors, so I can reproduce the error?
In /examples folder there is an advanced.html demoing 2 editors on one page (with iframe).

@arch0njw
Copy link
Author

This error appears on Windows and Linux.
Windows: IE, FF, Chrome
Linux: FF, Chromium

The error only happens when adding another editor dynamically. Imagine using a template system like knockout.js and a button click creates a modal with an editor in it. That modal comes from another template and technically did not exist in the DOM until ko's template engine injected it.

ALSO, FWIW, I am not using the editable divs. I am going to try that right now.

@arch0njw
Copy link
Author

The error went away when I used the DIV approach. I'll close this.

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

2 participants