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 created the WordPress editor using wp_editor function dynamically. While i click add more button i just cloned editor and append new editor using jquery. While i am cloning editor i just changing id distribution_0 to distribution_1 etc. Editor Properly creating, But editor tools of the dynamic editor is not working and producing js error like 'd' is not defined.

While go throw the wp_editor function codex. I saw notes about id should be used only lower case not any other like below. So i try to create 2 editor on same page directly using id with underscore (distribution__0) and it works fine. So is that statement falls in codex.Do you have any idea about this problem. kindly share with me.

Note that the ID that is passed to the wp_editor() function can only be comprised of lower-case letters. No underscores, no hyphens.> Anything else will cause the WYSIWYG editor to malfunction.

PHP code to create editor

wp_editor('content',
   'distribution__0,
   array(
   'media_buttons' => false,
   'textarea_rows' => 8,
   'textarea_name' => 'rw_toplist_description[]',
   'tabindex' => 4,
   'tinymce' => array(
   'theme_advanced_buttons1' => 'bold, italic, ul, min_size, max_size',

   ),
   )
); 
share|improve this question

2 Answers 2

The problem is that the wp_editor() automatic load the scripts and this is not possible dynamic. You must enhance your plugin, code and add the scripts also dynamic or via ajax. WP include the scripts and styles via wp_enqueue_script() and this is not usable in a dynamic change of DOM, it was registered for better control.

Hints for find all script and styles.

The funciton wp_editor() is only a wrapper for the class class _WP_Editors and in this class do you find all method and inlcuded scripts. see in wp-includes/clas-wp-editor.php. See the methods editor_settings and enqueue_scripts for include js and styles.

share|improve this answer
    
do you have idea about what are the scripts i should reload. –  gowri Oct 29 '12 at 9:43
    
i have update the answer with a little bid more informations, there you can find the scripts and styles. –  bueltge Oct 29 '12 at 10:06

I'm not sure about it but codex said "Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page."

Is your same javascript code working with other elements?

share|improve this answer
    
Yes working perfectly for other elements and editor works as well in meta box. so is this old statement. –  gowri Oct 29 '12 at 7:27
    
I'm not sure of this but it could be that the javascript variables are tied to the position of editor & when you try to clone or move it, it creates the error. Have you tried moving the meta box? –  Mridul Aggarwal Oct 29 '12 at 7:41
    
I dragged and dropped in different position of the page that works fine, No issue with that. –  gowri Oct 29 '12 at 7:47
    
then probably the codex needs a correction –  Mridul Aggarwal Oct 29 '12 at 8:03

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.