【发布时间】:2011-10-14 03:43:21
【问题描述】:
如何动态更新下拉菜单中的项目?
我有一个用于 CKEditor 的自定义插件,它填充了一个下拉菜单,其中包含我可以注入到我的 textarea 中的项目列表。
这个项目列表来自一个名为 maptags 的 Javascript 数组,该数组会针对每个页面动态更新。
var maptags = []
当您第一次单击init: 函数时,此标签列表会添加到下拉列表中。我的问题是,如果该数组中的项目随着客户端更改页面上的内容而更改,我该如何将该列表重新加载到更新后的数组中?
这是我的 CKEditor 插件代码:
CKEDITOR.plugins.add('mapitems', {
requires: ['richcombo'], //, 'styles' ],
init: function (editor) {
var config = editor.config,
lang = editor.lang.format;
editor.ui.addRichCombo('mapitems',
{
label: "Map Items",
title: "Map Items",
voiceLabel: "Map Items",
className: 'cke_format',
multiSelect: false,
panel:
{
css: [config.contentsCss, CKEDITOR.getUrl(editor.skinPath + 'editor.css')],
voiceLabel: lang.panelVoiceLabel
},
init: function () {
this.startGroup("Map Items");
//this.add('value', 'drop_text', 'drop_label');
for (var this_tag in maptags) {
this.add(maptags[this_tag][0], maptags[this_tag][1], maptags[this_tag][2]);
}
},
onClick: function (value) {
editor.focus();
editor.fire('saveSnapshot');
editor.insertHtml(value);
editor.fire('saveSnapshot');
}
});
}
});
【问题讨论】:
标签: javascript plugins ckeditor