我已经为WordPress 3.8创建了列表框,但它在新版本WordPress 3.9中不起作用。所以我编写了JavaScript代码:
(function() {
var ICONS;
var icon = function(id) {
return \'<i class="fa fa-\' + id + \'"></i>\';
}
ICONS = ["rub", "ruble", "rouble", "pagelines", "stack-exchange", "arrow-circle-o-right", "arrow-circle-o-left", "caret-square-o-left", "toggle-left", "dot-circle-o", "wheelchair", "vimeo-square", "try", "adjust", "anchor", "archive", "arrows", "arrows-h", "arrows-v", "asterisk", "ban", "bar-chart-o", "barcode", "bars", "beer", "bell", "bell-o", "bolt", "book", "bookmark", "bookmark-o", "briefcase", "bug"]
var menuval=[];
for (var i = 0; i < ICONS.length; i++) {
var _id = ICONS[i];
menuval.push({text: icon( _id )+\' \'+_id, onclick: function(){setcontentfun(_id)}
});
}
tinymce.PluginManager.add("font_awesome_glyphs", function(editor, url) {
var menucreate=editor.addButton(\'fontAwesomeGlyphSelect\', {
type: \'listbox\',
text: \'Icons\',
icon: false,
values: menuval
});
});
function setcontentfun(id) {
alert(id);
return false;
}
})();
因此,它创建了列表框并显示得很好,但是,当我单击菜单项时,它会提醒“ICON”数组的最后一个元素,在那里它可以很好地显示列表框中的所有元素。那么,如何提醒我单击的列表项呢?