We know such syntaxes as below, when defining a value
for onClick
attribute:
One way is to use eval()
jQuery(".container").on("click", "button.marker", function (e) {
var callback = jQuery(e.currentTarget).data("callback");
var x = eval(callback)
if (typeof x == 'function') {
x()
}
});
Demo: Fiddle
Note: Make sure it is safe in your environment, ie there is no possibility of script injection because of bad input from users