I have already created listbox for WordPress 3.8 but it's not working in new version WordPress 3.9. So I write the JavaScript code:

(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) {
    return false;

So, it creates the listbox and displays well, but, when I click on the menu item, it alerts last element of "ICON" array, where it displays all the elements in the listbox well. So, how can I alert the list item, which I clicked?

1 Answer 1


Well after long research I find out solution,

var menuval=[];
var insertVar = function (val) {
    return function () { 
for (var i = 0; i < SHORTCODES.length; i++) {
    var _id = SHORTCODES[i];
    var _code = SHORTCODE_EXE[i];
    var variable = insertVar(_code);
   //alert(_id+' '+ SHORTCODES[i]+' '+SHORTCODE_EXE[i]);
    menuval.push({text: _id, onclick: variable }); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.