ckeditor报错ckeditor 使用 uncaught exception: [CKEDITOR.editor] The instance

 config_front.js

 

$(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'; 

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

   jsp:

 

<td colspan="2"><textarea class="w660 h100 mb10"
										name="caseText"
										οnkeydοwn="if(this.value.length >2000) this.value=this.value.substr(0,2000);">
										<c:out value="${cases.caseText}" escapeXml="true"></c:out> </textarea></td>
 

表单验证:我把表单所有属性列出来了,暂时只需要看 案例正文。

 

function save() {
	/* 必检字段 */
	var LastName = $("#LastName").val();// 客户姓氏
	var title = $("#title").val();// 案例标题
	var age = $("#age").val(); // 客户年龄
	var occupation = $("#occupation").val();// 客户身份
	var Income = $("#Income").val();// 月均收入
	var AnnualPremium = $("#AnnualPremium").val();// 年缴保费
	var CustomerDemand = $("#CustomerDemand").val();// 客户需求
	var caseText = editor.document.getBody().getHtml();
	// var caseText = $("#caseText").val();// 案例正文
	var InsuranceCompany = $("#InsuranceCompany").val(); // 保险公司
	var InsuranceProducts = $("#InsuranceProducts").val(); // 保险产品
	var appellation = $("#appellation").val(); // 称谓
	var sex = $("#sex").val(); // 性别

	var id = $("#id").val(); // id

	// 判断空
	if ($.trim(title) == '') {
		alert('案例标题');
		return false;
	}

	if ($.trim(LastName) == '') {
		alert('请输入姓氏');
		return false;
	}

	if ($.trim(age) == '') {
		alert('请选择年龄');
		return false;
	}

	if ($.trim(occupation) == '') {
		alert('请填写客户身份');
		return false;
	}

	if ($.trim(Income) == '') {
		alert('请填写月均收入');
		return false;
	}

	if ($.trim(AnnualPremium) == '') {
		alert('请填写年缴保费');
		return false;
	}

	if ($.trim(CustomerDemand) == '') {
		alert('请填写客户需求');
		return false;
	}

	if (CustomerDemand.length > 200) {
		alert("客户需求字数不能大于200字");
		return;
	}

	if ($.trim(editor.document.getBody().getText()) == '') {
		alert('请填写案例正文');
		return false;
	}

	if (caseText.length > 2000) {
		alert("案例正文字数不能大于2000字");
		return;
	}

	if ($.trim(InsuranceCompany) == 0) {
		alert('请填写保险公司');
		return false;
	}

	if ($.trim(InsuranceProducts) == '') {
		alert('请填写保险产品');
		return false;
	}

	// 判断格式
	if (!nameCheck('title')) {
		alert('请填写正确格式的标题!');
		return false;
	}

	if (!nameCheck('LastName')) {
		alert('请正确输入姓氏');
		return false;
	}

	if (!nameCheck('occupation')) {
		alert('请填写客户身份');
		return false;
	}

	if (!numCheck('Income')) {
		alert('请填写月均收入');
		return false;
	}

	if (!numCheck('AnnualPremium')) {
		alert('请填写年缴保费');
		return false;
	}

	if (!numCheck("Income")) {
		alert('请填写月均收入!');
		return false;
	}
}

 

问题:我一进入页面之后报错,说我已经实例化了caseText,但是我只实例化一次啊。

 

解决方案:在页面中单独写个

 

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

 

即可, 把config_front.js的var editor = CKEDITOR.replace( 'caseText', { customConfig : 'config_front.js' }) ; 去掉即可。

 

 

还有其他的解决方式:

 

参考:http://www.toobull.com/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值