wp-editor is empty on first submit

Question

I’m using wp-editor in a simple plugin, but I’m having an issue where the first time I hit the submit button the content from it is blank in the database.

<?php 
$editor_id = 'mycontent';       
wp_editor($content, $editor_id );               
?>

So I tried alerting the content using this:

if (j(".wp-content-wrap").hasClass("tmce-active")){
   alert( tinyMCE.activeEditor.getContent());
}else{
   alert( j('#mycontent').val());
}

and the first submit comes up empty. If I switch to the text version before I submit, it works.

What am I doing wrong here that prevents the submit from working?

Edit: Interestingly, if I do this:

wp_editor('test', $editor_id );

It works.
If I do this:

wp_editor('', $editor_id );

It doesn’t work again.

How do I get it to work if the $content is initially blank?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/wp-editor-is-empty-on-first-submit/">

wp-editor is empty on first submit</a>
0
David 2 months 0 Answers 83 views 0

Leave an answer