如何使用jquery向ckeditor添加额外的数据? [英] How to add extra data to the ckeditor using jquery?

查看:263
本文介绍了如何使用jquery向ckeditor添加额外的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MVC3 CKeditor上工作,当我单击提交"按钮时,我需要向CKeditor中插入一些额外的数据.我怎样才能做到这一点?到目前为止,我的代码如下:这是我的html页面

I am working on MVC3 CKeditor and I need to insert some extra data into CKeditor when I click the submit button. How can I do this? My code so far is as follows: this is my html page

        <div id="div-child-Cat-Desc-Long" class="CKEditor-child-DIV">
                    @Html.TextAreaFor(m => m.Message, new { Class = "input-xlarge", @id = "txtAreasocial",@rows="3" })
                </div>

$(document).ready(function () {
    //Passing the Text Area reference to get the CK Editor
    var editor = CKEDITOR.editor.replace('txtAreasocial');
});

 $('#btnadd').click(function () {
    alert('hi');

    var data = "Hello. This is a new node.";
    alert(data);
    CKEDITOR.editor.setData(data);

    editor.setData(data)
});

推荐答案

使用"insertHtml"或"insertText"函数将数据附加到CKEDITOR中.像这样:

Use "insertHtml" or "insertText" function for appending data into the CKEDITOR. Like this:

CKEDITOR.instances['input-text-area-ID'].insertHtml(data);

这篇关于如何使用jquery向ckeditor添加额外的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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