question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'body' of undefined

See original GitHub issue

Sometimes exception occurs in getBody: function() { return this.bodyElement || this.getDoc().body; }

getDoc returns undefined. getDoc should return .document for iframe. But sometimes iframe is not created.

iframe is created by the following method:

/**
* Initializes the editor this will be called automatically when all plugins/themes and language packs are loaded by the rendered method.
This method will setup the iframe and create the theme and plugin instances.
*
* @method init
*/
init: function() {

So I think getBody is called before all plugins are loaded.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:30 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
mfilipcommented, Aug 25, 2016

The solution is simple for the getDoc() == undefined and for error with getBody. You need to modify angular ui directive in way like that: function toggleDisable(disabled) { if (disabled) { ensureInstance(); if (tinyInstance) { tinyInstance.getBody().setAttribute('contenteditable', false); } } else { ensureInstance(); if (tinyInstance && !tinyInstance.settings.readonly && tinyInstance.getDoc()) { tinyInstance.getBody().setAttribute('contenteditable', true); } } } So when you add additional check for getDoc then error is disapear at least for this was working for me to remove this error.

4reactions
fyrkantcommented, Mar 29, 2018

Is anyone still having this problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'body' of undefined after POST (MEAN ...
TypeError : Cannot read property 'body' of undefined after POST (MEAN) you will get this error when your localhost ip is changed or...
Read more >
Cannot read property 'body' of undefined · Issue #7562 - GitHub
This happened for me when the page redirected and there technically was no response. Chrome gets rid of response data when the page ......
Read more >
Cannot read property 'body' of undefined (Example) - Treehouse
Cannot read property 'body' of undefined. I've reviewed the video multiple times and I'm not seeing my error. Can anyone help?
Read more >
Cannot read property req body undefined in express - YouTube
codercrab #express # body -parserCannot read property req body undefined in express ||Express req body is undefined for post requests.
Read more >
[Solved] Cannot read Properties of Undefined in JavaScript
The "Cannot read properties of undefined" error occurs when you try to access a property or a method on a variable that stores...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found