`
woshixushigang
  • 浏览: 562248 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

ckeditor取值赋值问题

 
阅读更多

最近的项目中遇到个很头疼的问题,异步提交表单后需要清空表单数据,项目中文本编辑器是ckeditor,用了好几种方式都无法将提交后的表单清空。

最后发现这种方式可以:

 

				document.form1.reset();
				CKEDITOR.instances.caseText.setData(' ');
 

开始采用jquery的 $("#caseText").val(''); 试试之后发现此方式不成功。

 

采用: document.form1.caseText.value='' 发现也是不可以。

采用:

var o = $("#caseText").cleditor()[0];//关键是这里获取第一个对象,否则upateFrame无法调用 
          $('#caseText').html(' '); 

          o.updateFrame();  
	document.form1.reset();

 

不但没有清除表单值反倒把原来清空的都填回去了。

 

具体说下我配置ckeditor.

 

 

$(function() {
CKEDITOR.editorConfig = function( config )
{/*
	config.language = 'zh-cn';
	config.toolbar = 'Background';
	config.toolbar_Background = [
       ['Bold','Italic','Underline','Strike','-','Subscript','Superscript','RemoveFormat'],
	   ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo'],
        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
		['NumberedList','BulletedList','-','Outdent','Indent'],
       '/',
        ['Styles','Format','Font','FontSize'],
        ['TextColor','BGColor'],
		['Link','Unlink'],
		['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
		['Maximize','ShowBlocks']   
    ];
	config.resize_enabled = false;
	config.font_names = 'Arial;Verdana;Times New Roman;Georgia;Tahoma;宋体;黑体;微软雅黑';
	config.disableObjectResizing = false;
*/
	config.language = 'zh-cn';
	config.toolbar = 'Background';
	config.toolbar_Background = [
       ['Bold','Italic','Underline','Strike','-','Subscript','Superscript','RemoveFormat'],
	   ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo'],
        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
       '/',
        ['FontSize'],
        ['TextColor','BGColor'],
		['Link','Unlink','Table'],
	   ['NumberedList','BulletedList','-','Outdent','Indent'],
	   ['BidiLtr','BidiRtl']
    ];
	//config.entities = false;
	config.resize_enabled = false;
	config.disableObjectResizing = false;
	config.filebrowserImageUploadUrl = 'ckupload?type=Images'; 

};
CKEDITOR.replace( 'caseText', { customConfig : 'config_front.js' }) ;
});

 开始时候为了取值需要,将

var editor = CKEDITOR.replace( 'caseText', { customConfig : 'config_front.js' }) ;

设置成了全局变量,导致每次加载时候会报 存在实例错误。

 

 为了避免类似错误,建议使用:

 

				CKEDITOR.instances.caseText.setData(' ');

方式获取数据。

分享到:
评论
1 楼 simusuishi 2012-11-16  
刚哥威武!

相关推荐

    CKEditor在表单中使用

    在这个包中,包含了原来的代码,当时这里调用了CKEditor api中的js函数,从而解决了CKEditor的项目路径问题,在CKEditor的自定义标签中不支持表达式,所以不能使用项目路径,所以需要使用js代码解决

    ckeditor配置上传视频

    但网上很多配置都有问题,自己摸索了好久终于搞定。需要注意的细节有:flvPlayer文件夹的内容直接放在ckeditor文件夹里面的plugins文件夹下面。然后配置config.js文件的节点:config.extraPlugins = 'flvPlayer'; ...

    让ckeditor只读 让ckeditor只读

    把ckeditor 3.4的ckeditor.js复盖就行

    ckeditor Demo

    ckeditor

    Ckeditor菜单栏中字体、大小等选项在ie8、ie10中不能展开问题

    Ckeditor4菜单栏 Ckeditor4与ie兼容问题 菜单选项不能展开

    ckeditor文件管理按钮

    直接在ckeditor的按钮中显示文件浏览按钮,点击后打开文件浏览窗口,上传或管理文件(必须安装ckfinder先) config.js中添加名为File的按钮 config.js中添加 ... 创建目录 ...ckeditor/skins/v2/file.gif

    ckeditor4 行高插件

    本插件源码来自互联网,由于源代码基于ckeditor3.6.61,故对源码进行过简单修改,以求适应ckeditor4.4.7

    lineheight支持最新的ckeditor

    之前在网上下载的都不可以用,于是想尽办法发现是网上提供的是不支持最新的ckeditor.用法找见自己的ckeditor地址让后放到ckeditor/plugins/ 下,最后修改ckeditor/config.js,如果之前添加过工具则在 config....

    ckeditor5-v30 全工具版.rar

    ckeditor5-v30 全工具版 ,基本将免费的工具备齐了,源文件,可自行修改重新打包,node_modules 文件夹为包文件,该文件夹容量较大,在实际应用时可以删除,必须在网站模式使用,如:...该版本表格插件与微软的edge...

    ckeditor插件工具

    ckeditor插件工具,ckeditor插件工具,ckeditor插件工具,ckeditor插件工具,

    ckeditor4音频视频上传自定义插件

    ckeditor4音频视频上传自定义插件

    ckeditor4.4

    ckeditor

    ckeditor4.3.2

    ckeditor4.3.2

    ckeditor4.0 最新版本

    不错编辑器 最新版本ckeditor4.0 最新版本

    CKEditor 4.0 行距插件lineheight

    用于最新CKEditor4.0的行距插件,不能用于CKEditor3.X.X及以前版本

    ckeditor最新

    ckeditor最新

    CKEditor FLV视频播放插件

    FLV视频格式具有本身占有率低、视频质量良好、体积小等特点,非常适合在网络...但是,在新版本的CKEditor里却没有FLV格式视频的支持。于是我自己动手开发CKEditor的FLV视频播放插件现在上传。PS:这个版本是.net版的。

    ckeditor文件

    ckeditor文件

    ckeditor 行间距插件

    ckeditor 行间距插件

    CKEditor操作(操作说明)

    <%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>-------引进CKEditor控件 【图书特色】 <CKEditor:CKEditorControl ID="bookFeature" runat="server" ></CKEditor:...

Global site tag (gtag.js) - Google Analytics