드롭 다운의 항목을 어떻게 동적으로 업데이트합니까?CKEditor Combobox/드롭 다운 메뉴를 다시 초기화 할 수 있습니까?
나는 textarea
에 삽입 할 수있는 항목 목록이있는 드롭 다운 메뉴를 채우는 CKEditor 용 사용자 정의 플러그인이 있습니다.
이 항목 목록은 각 페이지마다 동적으로 업데이트되는 maptags
이라는 자바 스크립트 배열에서 가져옵니다. 먼저 init:
기능에 의해 그것을 클릭하면
var maptags = []
태그이 목록
는 드롭 다운에 추가됩니다. 내 문제는 클라이언트가 페이지에서 내용을 변경함에 따라 배열의 항목이 변경되면 어떻게 업데이트 된 배열에 해당 목록을 다시로드 할 수 있습니까? 난 그냥 실제로이 문제를 해결할 생각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"배열에 넣습니다. –
약간 지저분하지만 올바른 방향으로 나를 잡았습니다. 감사! 추신. richCombo 객체의 구조가 이상하고 재미 있습니다.이 기능은 실제로 외부에서 해킹하지 않아도 richCombo의 일부가되어야합니다. –