So I'm trying to put in additional buttons into my tinyMCE wysiwyg editor on wordpress. They're showing up and are functioning (sort of). When clicked they're just outputting the last variable in the array, which is weird because I am using the variable in other places in the loop and it works fine.
(function() {
tinymce.create('tinymce.plugins.col', {
init : function(ed, url) {
var col_id = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven'];
for(var i = 0; i < col_id.length; i++){
var colNum = col_id[i];
ed.addButton(colNum+'_col', {
title : colNum+' Column',
image : url+'/images/mce/'+colNum+'.png',
onclick : function() {
ed.selection.setContent('['+colNum+'_col]' + ed.selection.getContent() + '[/'+colNum+'_col]');
}
}); // ***** Col *****
ed.addButton(colNum+'_col_first', {
title : colNum+' Column First',
image : url+'/images/mce/'+colNum+'.png',
onclick : function() {
ed.selection.setContent('['+colNum+'_col_first]' + ed.selection.getContent() + '[/'+colNum+'_col_first]');
}
}); // ****** Col First ******
ed.addButton(colNum+'_col_last', {
title : colNum+' Column Last',
image : url+'/images/mce/'+colNum+'.png',
onclick : function() {
ed.selection.setContent('['+colNum+'_col_last]' + ed.selection.getContent() + '[/'+colNum+'_col_last]');
}
}); //********* Col Last **********
}
},
createControl : function(n, cm) {
return null;
},
});
tinymce.PluginManager.add('col', tinymce.plugins.col);
})();
What happens when I click one of the buttons is it output the short code of [eleven_col][/eleven_col], which confuses me because the Title and image url is output correctly.