javascript - ExtJS:HTMLEditor 在 Accordion 重新展开时丢失内容

标签 javascript extjs

我有一个具有典型设置的 Accordion 面板。在每个面板中曾经有一个 textarea 并且一切正常。

现在我用 htmleditor 替换了每个 textarea。当我折叠面板并重新展开它时,htmleditor 的内容丢失了。当我使用 textarea 时,这并没有发生。如何解决这个问题?

已编辑:另外,当重新展开时,htmleditor 卡住,我无法输入任何内容。但按钮有效(粗体、插入链接、切换到源代码编辑等)。更奇怪的是,当我两次切换“切换到源”按钮时,内容以不同的字体重新出现!

使用 Accordion :

myDataStore.load({params: ...}, callback: onLoadSuccess);
......

onLoadSuccess: function() {
    // for each data item, create a new panel and add it to myListPanel
    for (var i = 0; i < myDataStore.getTotalCount(); i++) {
        var dataItem = myDataStore.getAt(i);
        var newFormPanel = new Ext.FormPanel({
            labelAlign: 'top',
            items : [{
                xtype: 'htmleditor',
                fieldLabel: 'Content',
                autoScroll: true,
                enableFont: false,
                enableLists: false,
                value: dataItem.get('content');
            }],
            buttons: [{...}]
        });
        // add this panel to the accordion
        myListPanel.add({
            title: 'Another panel',
            items: [newFormPanel]
        });
    }
    myListPanel.doLayout();
}

当前 Accordion 配置:

var myListPanel = new Ext.Panel({
    autoHeight : true,
    autoWidth: true,
    autoScroll : true,
    layout : 'accordion',
    layoutConfig : {
        titleCollapse: true,
        animate: true,
        fill : false,
        autoWidth: true,
        hideCollapseTool: true,
    },
});

最佳答案

对我来说,htmleditor 在折叠和展开时不会丢失内容。

但是,一种解决方案是监听 collapse 事件并将当前编辑器内容存储到属性中。 在 expand 事件中,您将其再次放置在编辑器中。

关于javascript - ExtJS:HTMLEditor 在 Accordion 重新展开时丢失内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20646858/

相关文章:

javascript - 带按钮的自动幻灯片

extjs - 是否可以在 'width: 100%' 元素上使用 Ext.Ressized?

extjs - 我在哪里可以找到关于 ExtJS 模板的好的文档?

javascript - ExtJS网格: why the focused line also selected it?

javascript - React js 中的 Bootstrap 模式不起作用

javascript - JavaScript 中的特殊字符编码

javascript - 首次访问时出现 Cookie NaN 错误

javascript - 有没有更干净的方法来删除非字母数字字符并替换空格?

javascript - 如何在 Raphael 元素上添加上下文菜单?

javascript - 设置开始日期字段 EXTJS