1
我試圖在onselect事件中獲取項目'data-id'屬性,但沒有運氣。如何從tinymce listbox控件項目中獲取屬性值
這裏我的代碼:
createControl: function (n, cm) {
switch (n) {
case 'ColorTextBox':
var mlb = cm.createListBox('ColorTextBox', {
title: 'color texto',
onselect: function (v) {
var ed = tinymce.activeEditor;
ed.formatter.register('custom_format', { inline: 'span', styles: { color: '%value' }, classes: 'color_text', attributes: { 'data-color': '%value' } });
ed.formatter.apply('custom_format', { value: v });
}
});
for (i in CssStyles.colors.text) {
mlb.add('color texto #' + i, CssStyles.colors.text[i], attributes = { 'data-id': i }); //-> Is this attribute reachable from onselect event or is there a way?
}
return mlb;
break;
}
}
}
有什麼建議?非常感謝你。