0

Setup a basic WPAlchemy repeater field with a TinyMCE textbox inside. If repeated I am unable to select the new textbox and add text.

If I remove TinyMCE it works fine however. Please help.

functions.php:

// Tiny mce metaboxes
add_action('admin_print_footer_scripts','admin_print_footer_scripts',99);
function admin_print_footer_scripts()
{
    ?><script type="text/javascript">/* <![CDATA[ */
        jQuery(function($)
        {
            var i=1;
            $('.temp_options_desc').each(function(e)
            {
                var id = $(this).attr('id');

                if (!id)
                {
                    id = 'temp_options_desc-' + i++;
                    $(this).attr('id',id);
                }

                tinyMCE.execCommand( 'mceRemoveEditor', false, id );
                tinyMCE.execCommand( 'mceAddEditor', false, id );

            });
        });
    /* ]]> */</script><?php
} 

metabox_template.php:

<div class="my_meta_control">

<?php global $wpalchemy_media_access; ?> 
<h2>Awards</h2>

            <?php while($mb->have_fields_and_multi('awards2')): ?>
            <?php $mb->the_group_open(); ?>

                <h3>Award</h3>


                <label>Awards Year:<br /> 
                <?php $mb->the_field('award-year2'); ?>
                <input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" placeholder="2000" style="width:150px !important;" /></label>


                <label>Award Content:<br />
                <?php $mb->the_field('award-content2'); ?>
                <textarea style="width:100%;height: 50px;" class="temp_options_desc" name="<?php $mb->the_name(); ?>"><?php echo wp_richedit_pre($mb->get_the_value()); ?></textarea></label>   

                <a href="#" title="Remove" class="dodelete button"><strong>X</strong></a>


            <?php $mb->the_group_close(); ?>
            <?php endwhile; ?>

    <p style="margin-bottom:15px; padding-top:5px;"><a style="margin:10px 10px 10px 0px;" href="#" class="dodelete-awards2 button">Remove All</a> <a href="#" style="margin:10px 10px 10px 0px;" class="docopy-awards2 button">Add Award</a></p> 

    <!-- REPEATER END -->
</div>
  • Tinymce 4 had a lot of changes. Are you using the latest wordpress? This occured with many plugins due to the new changes. – Bryan Willis Jun 13 '14 at 17:57
0

While it's hard to give answers without knowing version numbers of plugin/theme/tinymce/wp/etc, my best guess is that it's issues from the new tinymce4.

I dealt with this a few months ago, here's a github repo with an example on how to use with the new editor.

If this is not the issue, or you are not using the new tinymce please provide more info (version numbers).

  • Cheers Willow, will check some point this weekend and let you know :) I dont mind if you post a link so long as it helps! – leannekera Jun 13 '14 at 22:07
  • Hi Willow, this works great, I now just need to integrate it with my template argh! - Thank you for your help :) – leannekera Jun 16 '14 at 8:53
  • Haha yea glad it worked! – Bryan Willis Jun 29 '14 at 7:38
-1

I had a similar problem while I was trying to use ToncyMCE 4 in internet explorer 8 "IE=8"(yes an old version for the sake of an old version of dojo being using in the same project and I don't have time to update it : ) ).

I had multiple TinyMCE editors in my page , teh firts was working very well but I couldn't add text in the next editors.

I found that the latest version was not the supporting older versions of IE , so I had to go back to an older version on TinyMCE 3.x and now it's working fine.

  • Answers should be more than plain links. They should actually be an answer instead of a route where someone will maybe find an answer. Please help preventing link rot. Also please do not link to blog posts that only contain what is already in the question... "For more details please check [my blog post]" does not provide more information. – kaiser Dec 18 '14 at 8:27
  • Thanks for your comment , it's fine that you have deleted the link to blog post.But I was clear enough in mentioning my problem and the solution I came up with , which is alreayd working in my case. The reason to add an answer here was to have a look at another possibility of the cause of this problem and what is the solution. Please don't judge other's intentions and read twice before commneting or giving it a negative , we are all here to help each other right. This community is helping me alot and I am just trying to contribute , such harsh statements like yours will just discourage others. – Sajjad Ahmed Paracha Dec 22 '14 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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