Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am making a small live preview area inside a meta box using jquery where i need to get content from tinymce editor. But it seem my script loads before tinymce, this returns null when i try to get content from editor field.

Enqueue:

add_action('admin_enqueue_scripts', 'wpk_popup_admin_script', 100);

function wpk_popup_admin_script($hook) {
    global $post;
    if( 'edit.php' != $hook && $post->post_type != 'wpk_popup'  )
        return;

    if(is_admin()){
        wp_enqueue_script( 'jquery' );

        wp_register_script( 'wpk-popup-admin', plugins_url('/js/admin.js', __FILE__), array('jquery'), false, true);
        wp_enqueue_script( 'wpk-popup-admin' );
    }

}

Tried adding editor on dependency but its no use. The script prints just before the tinymce configuration.

enter image description here

jQ Code for getting editor content:

html += jQuery('#content_ifr').contents().find('#tinymce').html();

Which returns NULL.

share|improve this question
did you try to use: tinyMCE.activeEditor.getContent(); ? – ungestaltbar Dec 15 '12 at 10:03
@ungestaltbar: activeEditor is NULL too. My guess is i have to print the script after the tinyMCE initialization. – Sisir Dec 16 '12 at 7:55

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.