Currently in TinyMCE 4 I'm trying to add emoticons as buttons in my toolbar.
The code below works fine, I can see all buttons in the toolbar:
var array = ['applause', 'bumping', 'cool', 'cry', 'grin', 'happy', 'laughing', 'notalking', 'sad', 'wink'];
for (var i in array) {
editor.addButton(array[i], {
title: '',
icon: true,
image: 'img/smileys/'+ array[i] +'.gif',
onclick: function() {
editor.execCommand('mceInsertContent', false, '<img src="img/smileys/'+ array[i] +'.gif">');
}
});
}
However, the array[i]
in the editor.execCommand
line, always return its value as wink
(last value of the array). Meanwhile, the other two instances of array[i]
in the code works just fine.