Want to load wp_editor using JQuery in WordPress? Use following code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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 like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.