sunalb 于 2015.06.03 00:44 提问
- ExtJS 整合 百度 UEditor
-
Ueditor.js
Ext.define('Ext.ux.Ueditor',{ extend: 'Ext.form.FieldContainer', mixins:{ field:Ext.form.field.Field }, alias: 'widget.ueditor',//xtype名称 alternateClassName: 'Ext.form.UEditor', ueditorInstance: null, initialized: false, initComponent: function () { var me = this; me.addEvents('initialize', 'change'); // 为ueditor添加一个初始化完成的事件 var id = me.id + '-ueditor'; me.html = '<script id="' + id + '" type="text/plain" name="' + me.name + '"></script>'; //调用当前方法的父类方法详见Ext.Base me.callParent(arguments); me.initField(); me.on('render', function () { var width = me.width - 105; var height = me.height - 109; var config = {initialFrameWidth: width, initialFrameHeight: height}; me.ueditorInstance = UE.getEditor(id, config); me.ueditorInstance.ready(function () { me.initialized = true; me.fireEvent('initialize', me); me.ueditorInstance.addListener('contentChange', function () { alert(111); me.fireEvent('change', me); }); }); }); }, getValue: function () { var me = this, value = ''; if (me.initialized) { value = me.ueditorInstance.getContent(); } me.value = value; return value; }, setValue: function (value) { // alert(value); var me = this; if (value === null || value === undefined) { value = ''; }else{ me.isChanged = true; } if (me.initialized) { me.ueditorInstance.setContent(value); } return me; }, onDestroy:function () { this.ueditorInstance.destroy(); } });
NEWUPDATE.JS
{ style: 'margin-top:3px', xtype: 'ueditor', id: 'newsContent', name: 'content', fieldLabel: '新闻内容', height: 270, allowBlank: false }] });
添加没有问题。为什么setValue就有问题了??求大神!!!!
补充:JSDUBUG value是有值的。但是 if (me.initialized) { 每次setValue 为false. 而且好像没有走 me.ueditorInstance.addListener('contentChange', function () {
alert(111);方法。
-
- jiuqiyuliang 2015.06.03 09:10
-
-
showbo
2015.06.03 10:18
开发工具看下是否报错
if (me.initialized) { 每次setValue 为false这个是什么意思?ueditor编辑器更新了内容么有?如果更新了那么说明你的contentChange事件没加上
-
- sunalb 2015.06.03 23:18
控件集成没问题 。添加都已经可以了。就是修改的时候。设置不了值
-
- yahui870718 你是怎么解决的?
- 接近 3 年之前 回复
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!