原文地址:http://blog.csdn.net/resigshy/article/details/7937021
ExtJS与KindEditor整合的方式。
- /**
- * 将KindEditor4.1.2 功能封装到命名空间“KE“。
- * @author shuyuan
- */
- Ext.namespace("KE");
- KE.app = (function() {
- return {
- /**
- * 初始化editor
- * @param initParam 初始参数。
- * @returns
- */
- init : function (initParam){
- setTimeout(function(){
- KindEditor.create('#' + initParam.renderTo, initParam);
- }, ((!initParam.delayTime || initParam.delayTime) <= 0 ? 5 : initParam.delayTime));
- },
- /**
- * 获取创建后的editor对象。
- * @param renderTO textarea的ID,根据此参数查找已创建的editor对象
- * @returns
- */
- getEditor : function(renderTO) {
- var editors = KindEditor.instances;
- for(var i = 0; i < editors.length; i++){
- if(editors[i].renderTo && editors[i].renderTo === renderTO){
- return editors[i];
- }
- }
- }
- };
- })();
初始化KindEditor:
- var contentFormPanelCn = new Ext.form.FormPanel({
- id : 'contentFormPanelCn',
- title:mpdLang.chinese, //'中文',
- layout : 'fit',
- bodyStyle:"border:0px;padding:0px",
- defaultType : 'textfield',
- items : [{
- xtype:'textarea',
- id:'contentCn',
- 'auto',
- height:'auto'
- }],
- listeners:{
- 'render':function(){
- KE.app.init({
- renderTo : "contentCn",
- delayTime : 1,
- readonlyMode : false,
- resizeType : 0,
- width : '100%',
- minChangeSize : 20,
- imageTabIndex : 1,
- uploadJson : ""
-
- });
- }
- },
- buttons:[{
- text:commonality_save,//保存
- id:"btnEditContentCn",
- handler : function() {
- var html = KE.app.getEditor('contentCn').html();//取值
- }
- }],
- buttonAlign:'center'
- });