Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried to add an editor into the metabox dynamically. But after adding it is falling to switch editors from html to visual.

My ajax call to get the editor

   dataString = 'action=' + admin_object.action_editor + '&security=' + admin_object.action_editor_security + '&count=' + count;

            type: "POST",
            url: admin_object.ajax_url,
            data: dataString,
            success: function(resultData){
                jQuery('.woocommerce_product_tab_wrapper').stop(true).css('opacity', '1').unblock();
                tinyMCE.settings = tinyMCEPreInit.mceInit.content;
                tinyMCE.execCommand('mceAddControl', false, 'wptb_content_'+tab_count);
                switchEditors.switchto({'id' : 'wptb_content_'+tab_count+'-html'});
                jQuery("#wptb_content_"+ tab_count +"_ifr").contents().find(".qp").css("background-color","#00ff00");
                jQuery('.woocommerce_product_tab_wrapper .tabs').find('li.'+tab_title_slug + '_tab a').click();

My Ajax function call

    public function get_editor() {
        check_ajax_referer( 'get-editor', 'security' );
        $tabcount = isset($_POST['count']) ? $_POST['tabcount'] : '';
        if(!is_numeric($count) && $count < 0) die();

        $settings = array(
            'quicktags'     => array( 'buttons' => 'em,strong,link' ),
            'textarea_name' => 'content[]',
            'quicktags'     => true,
            'tinymce'       => true,
            'editor_css'    => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;background:#FFFFFF;}</style>'

        wp_editor( htmlspecialchars_decode( '' ), 'content_'.$tabcount, $settings );
share|improve this question
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.