I want to add WordPress editor dynamically using jquery in my custom plugin as follow:
<?php
$content = '';
$editor_id = 'mycustomeditor';
?>
$('#container').append('<?php wp_editor( $content, $editor_id );?>');
I am getting error:
SyntaxError: missing ) after argument list
...-active"><link rel='stylesheet' id='editor-buttons-css' href='http://localhost
I have also tried bellow code(here I have replaced single quotes to double quotes):
<?php
$content = '';
$editor_id = 'mycustomeditor';
?>
$('#container').append("<?php wp_editor( $content, $editor_id );?>");
I am getting error:
SyntaxError: missing ) after argument list $('#container').append("<div id="wp-mycustomeditor-wrap" class="wp-core-ui wp-ed...
If you have any solution please let me know.
Thanks in advance
I know late answer. but it will help others. Try this jQuery plugin.
https://github.com/anteprimorac/js-wp-editor
you can use simple like below
jQuery(document).ready(function (){
jQuery('#container').wp_editor();
});
add_action('init','my_wpEditOUPUTT');function my_wpEditOUPUTT(){
if (isset($_POST['Give_me_editorrr'])){
wp_editor( '' , 'txtrID_'.$_POST['myNumber'], $settings = array( 'editor_class'=>'my_class', 'textarea_name'=>'named_'. $_POST['myNumber'], 'tinymce'=>true , 'media_buttons' => true , 'teeny' => false,));
exit;
}}
<div id="MyPlace"></div> <a href="javascript:myLoad();">Click to load</a>
<script type="text/javascript">
startNumber = 1;
function myLoad(){ alert('wait 1 sec');
startNumber ++;
$.post('./index.php', '&Give_me_editorrr=1&myNumber='+startNumber ,
function(data,status){
if (status == "success") {
document.getElementById('MyPlace').innerHTML += data; alert("Inserted!");
tinymce.init({ selector: 'txtrID_'+startNumber, theme:'modern', skin:'lightgray'}); tinyMCE.execCommand('mceAddEditor', false, 'txtrID_'+startNumber);
}
});}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With