【问题标题】:ExtJS: HTMLEditor loses content on Accordion re-expandExtJS:HTMLEditor 在 Accordion 重新展开时丢失内容
【发布时间】:2013-12-19 01:25:31
【问题描述】:

我有一个带有典型设置的手风琴面板。在每个面板中曾经有一个 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,
    },
});

【问题讨论】:

  • 你能发布你的完整工作代码吗?
  • 完整代码会太长...我更新了Accordion 的用法:新面板从数据存储添加到手风琴面板。
  • 更新:我将animate 转为false,问题解决了! @_@

标签: javascript extjs


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多