wx_Sean 2015-06-02 16:44 采纳率: 0%
浏览 4365

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);方法。

  • 写回答

3条回答

  • 程序猿小亮 Java领域优质创作者 2015-06-03 01:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?