TinyMCE的的execCommand返回undefined [英] TinyMCE execCommand return undefined

查看:356
本文介绍了TinyMCE的的execCommand返回undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除我刚才创建了一个特定的textarea tinyMCE的,但下面的命令不停地生产未定义的错误(使用Firebug的控制台检查):

I'm trying to remove tinyMCE from a specific textarea that I have created earlier but the following command kept on producing "undefined" error (checked using firebug console):

tinyMCE.execCommand('mceFocus', false, 'textarea-plainText');
tinyMCE.execCommand('mceRemoveControl', false, 'textarea-plainText')

我已经初始化TinyMCE的使用jQuery的特定文本区:

I have initialized the TinyMCE for that particular text area using jQuery:

$('textarea#textarea-plainText').tinymce({
                script_url : '<?php echo base_url(); ?>/assets/js/tinymce/tinymce.min.js',
                oninit: function() {
                            $("textarea#textarea-plainText").tinymce().setContent("");
                            $("textarea#textarea-plainText").tinymce().setContent(noteSecContent.html[0].notesec_content);
                        }
            });

我也尝试使用下面的命令来添加TinyMCE的,但它也将返回不确定的,虽然我有一个textarea文本区域明文ID:

I have also try to add tinyMCE using the following command but it also return undefined although I have a textarea with "textarea-plainText" ID:

$.getScript('<?php echo base_url(); ?>assets/js/tinymce/tinymce.min.js', function() {
            window.tinymce.dom.Event.domLoaded = true;
            tinyMCE.init({
                mode: 'none'
            });
            tinyMCE.execCommand('mceAddControl', false, 'textarea-plainText');
        });

总之,我只能要么使用jQuery的方法或确切的方法初始化。但不使用tinyMCE.execCommand。不知何故,exeCommand命令只是不会工作。

In short, I can only initialize either using the jquery method or exact method. But not using tinyMCE.execCommand. Somehow the "exeCommand" command just wont work.

HTML的textarea的:

HTML for the textarea:

<div id="plainTextModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="plainTextLabel" aria-hidden="true">
  <div class="modal-body">
   <textarea id='textarea-plainText'></textarea>
  </div>
  <div class="modal-footer">
    <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Cancel</button>
    <a href="" id="confirm-delete-note-section" class="btn btn-primary">Save</a>
    <a href="" id="confirm-delete-note-section" class="btn btn-info">Save &amp; Close</a>
  </div>
</div>

这是一个模式,所以它最初是隐藏的,直到模式被调用。

It's a modal, so it is initially hidden until the modal is called.

我使用的TinyMCE 4.0b1的方式。

I'm using TinyMCE 4.0b1 by the way.

推荐答案

您得到不确定,因为在4.x中他们删除 mceRemoveControl mceAddControl (我不知道 mceFocus ),所以使用 mceAddEditor mceRemoveEditor 代替。

You get undefined because in 4.x they removed mceRemoveControl and mceAddControl (I'm not sure about mceFocus) so use mceAddEditor and mceRemoveEditor instead.

由于这些codeS也做了同样的东西,他们在清理删除 mceRemoveControl mceAddControl

Because these codes did the same stuff they removed mceRemoveControl and mceAddControl in the cleanup.

和也不要忘了,你需要从现在开始使用 TinyMCE的小写。

And also don't forget you need to use tinymce in lower case from now.

这篇关于TinyMCE的的execCommand返回undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆