JSFiddle - React, Tailwind, and code Playground
JavaScript
$(function() {
var customCommands = {
command1: {
text: 'Hello Console',
cFunctionRun: function() {
console.log('hello Console!');
}
},
command2: {
text: 'Hello World',
cFunctionRun: function() {
alert('hello World!');
}
}
}
for(i in customCommands) {
var command = customCommands[i];
button = $('<button/>').html(command.text).data("command_name", command).on('click',
function(){
console.log($(this).data("command_name"));
$(this).data("command_name").cFunctionRun();
}
);
$("body").append(button);
}
});