wp_editor: How to load wp_editor on demand using jQuery?

user2899728

I am trying to load wp_editor on demand using jquery/javascript.

Somehow I got success using following code but it does not save changed data in the element.

tinyMCE.execCommand('mceAddEditor', false, textarea_id);

I'll really appreicate any contribution.

Firefog

When we use wp_editor() it loads WordPress default visual editor. You must load:

<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>

Working example : http://jsfiddle.net/rupomkhondaker/j7brgyL2/

<textarea id="test">Easy features.</textarea>

And the code is

$(document).ready(function() {
    tinyMCE.init({
        mode : "none"
    });
    tinyMCE.execCommand('mceAddEditor', false, 'test');
});

Simply use

tinymce.execCommand('mceAddEditor', false, 'textarea_id');

Here is another example example:

<textarea name="sectionContent_1" id="sectionContent_1"></textarea>

script:

var textAreaID = 'sectionContent_' + sectionID;
$(this).parent()
    .find('.sectionOptions')
    .html(ctHolder).ready(
        function() {
            tinyMCE.execCommand('mceAddEditor', false, textAreaID); 
        }
    );

and the most simple way is

tinyMCE.execCommand("mceAddEditor", false, id);
tinyMCE.execCommand('mceAddControl', false, id);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

load wordpress wp_editor dynamically (ajax)

From Dev

Using wp_editor output correctly

From Dev

Error in buddypress when using wp_editor

From Dev

wordpress how to add wp_editor in an array

From Dev

How to detect changes in wp_editor?

From Dev

using wp_editor to edit post title on the front end

From Dev

WordPress wp_editor removes html tags - how to stop it?

From Dev

How to properly use wp_editor() from frontend

From Dev

Replacing a textarea with WordPress TinyMCE wp_editor()

From Dev

Include TinyMCE plugins with Wordpress wp_editor?

From Dev

Prevent wp_editor to alter initial content

From Dev

Replacing a textarea with WordPress TinyMCE wp_editor()

From Dev

WP Editor - wp_editor() is not showing properly on ajax call

From Dev

<p></p> missing with wp_editor( get_option() );

From Dev

WordPress load PHP plugin on demand with jQuery / AJAX?

From Dev

How to load iframe on load using jquery?

From Dev

How to Load PowerShell Functions On-Demand?

From Dev

wp_enqueue_script('jquery') does not load jQuery in WordPress 4.9.5?

From Dev

How to clear value in tejquery text editor using jquery or javascript

From Dev

How to load website HTML using jquery

From Dev

How to add an attribute on load time using jquery

From Dev

How to load a portion of a Page Using Ajax in JQuery?

From Dev

How to switch images with jQuery using .load()?

From Dev

How to load cross domain html using jQuery

From Dev

Using jquery how to refresh the contents of .load()

From Dev

How to load jquery in my gsp using layout

From Dev

how to load a file and parse tags using jquery

From Dev

How to load the content of <h> element using jquery

From Dev

How to load and validate a form using jquery?

Related Related

HotTag

Archive