ドロップダウンの項目を動的に更新するにはどうすればよいですか?CKEditor Combobox /ドロップダウンメニューを再初期化することはできますか?
私はtextarea
に注入できる項目のリストをドロップダウンメニューに入力するCKEditor用のカスタムプラグインを持っています。
この項目のリストは、maptags
と呼ばれるJavascript配列に由来し、ページごとに動的に更新されます。
var maptags = []
あなたが最初init:
機能によって、それをクリックすると、タグのリストは、ドロップダウンに追加されます。私の問題は、クライアントがページ上のものを変更すると、その配列の項目が変更された場合、そのリストを更新された配列にどのように再ロードできますか?私はちょうど実際にこれを解決すると思う
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');
}
});
}
});
に役立ちます。このソリューションは、静的データと正常に動作しますが、私は、サーバーから取得したデータと上記の溶液を使用しようとすると、それは空白を示しています。手伝ってくれますか? –
サーバーからアイテムを取得します。 Ajaxから呼び出され、 "yourListOfItems"配列に入れてください –
これはちょっと面倒ですが、それは正しい軌道に乗っています。ありがとう! p.s. richComboオブジェクトの構造は奇妙でおかしく、この機能は実際には外部からハックするのではなく、richComboの一部でなければなりません。 –