我有一个具有典型设置的 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/