【发布时间】:2014-07-25 00:37:35
【问题描述】:
当 CQ.form.RichText 添加到 cq5 中的自定义多字段小部件时,当再次打开对话框以编辑或添加自定义小部件的新条目时,富文本组件的内容会消失。 单击确定会使 cq 组件的 .html 页面上的内容消失。
寻找意见,如果有人遇到过此类问题,请您指导我解决方法。
编辑:
这是来自 custom.js 的代码示例(仅发布 RichText 部分,自定义小部件中有 DateTime 和 TextField 以及富文本)
this.news= new CQ.form.RichText({
cls: "customwidget-4",
fieldLabel: "News",
allowBlank: false,
listeners: {
change: {
scope: this,
fn: this.updateHidden
},
destroy: {
scope: this,
fn: this.descDestroy
}
}
});
this.add(this.news);
这里是 descDestroy sn-p:
descDestroy: function() {
this.news.el.dom = {};
}
然后将自定义小部件注册为 xtype:
CQ.Ext.reg("CustomNews", CQ.form.CustomNews);
在 dialog.json 中使用上述“CustomNews”:
{
"title": "Custom News Widget",
"jcr:primaryType": "cq:Dialog",
"xtype": "dialog",
"items": {
"jcr:primaryType": "cq:WidgetCollection",
"tab1": {
"jcr:primaryType": "cq:Widget",
"title": "News Component",
"xtype": "panel",
"items": {
"jcr:primaryType": "cq:WidgetCollection",
"news": {
"jcr:primaryType": "cq:Widget",
"fieldDescription": "Press + to add more links",
"fieldLabel": "News",
"hideLabel": false,
"name": "./news",
"width": 1000,
"xtype": "multifield",
"fieldConfig": {
"jcr:primaryType": "cq:Widget",
"xtype": "CustomNews"
}
}
}
}
}
}
提前致谢。
【问题讨论】:
-
我会尝试调试,特别是如果您使用自定义多字段小部件。这可能非常棘手,而且多字段很难处理。
-
请发布与问题相关的代码 sn-p 以便其他人可以调试/建议修复。还要添加您正在使用的 CQ5 版本。
-
第一次编辑数据时,它会转到 crx 吗?为了让多字段将数据存储在 crx 中,您可能需要更改 xtype 多字段的 getValue 和 setValue。简而言之,使用多字段存储的数据始终是字符串数组表示,因此文本字段的多字段将每个文本字段的数据存储在字符串数组中,这对于富文本是不同的。请检查数据是否在 crx 中发布,稍后在编辑组件时会发生获取请求,这就是您需要调试的地方。
-
@yashahuja,感谢您的意见,实际上我早在 7 月份就解决了这个问题。我会尽快更新这个问题。