tiff / wysihtml5

Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.
http://xing.github.com/wysihtml5/
MIT License
6.48k stars 995 forks source link

TypeError: Element is null - return element.classList.add(className); #488

Open faaabii opened 10 years ago

faaabii commented 10 years ago

Hey! I successfully integrated the wysithtml5 editor into my web app. Everything works fine, but:

Each of my entries has an individual ID and according to these ID's I call a function, e.g. getEntry(id), to open that entry. Within that entry I have 2 wysihtml5 editors. When I call my function with Eventhandlers, everything works fine.

Now I want to give the possibility to use URLs. The user types the following url into his browser:

http://mywebsite.com/?=2323

When loading the website, it discovers that link and it seperates the ID into a variable. If there is a variable, I call my function -> getEntry(2323);

There is nothing wrong and it successfully calls all actions within the function until it reaches the first wysihtml5 editor. It then throws the following error in firebug and stops the function:

TypeError: element is null

This error appears in wysihtml5-0.3.0.js in line 4066 with the following code:

return element.classList.add(className);

I can't find any mistakes. It's the correct ID and the function is called like all the time.

I hope you can help my or give me any hints.

Thanks in advance!

faaabii commented 10 years ago

I finally found out, that I had to load the site completely before loading the function. :( Sorry for this stupid mistake.

But I'm running in a new error instantly... it only shows the textarea and not the wysihtml5 editor...

It seems like it won't initiate the wysithml5 fields... :( Firebug throws the error:

TypeError: iframe.contentWindow is null

I googled for that and it tells me to first load the page completely, but thats what I'm doing. I have an $(document).ready() function and within this function I call the function to create the form. So the page should be ready to get it working... :(