I\'m using (or at least starting with) HandlebarsJS for the html templates but I might have hit a dead end. What I want is to pass a function to the template, e.g.
You can also make global defined callback function, and pass function calling string in the onclick value in the template.
Note the parenthesis with the tmpCallback for func value in data object.
var tmpCallback = function () {
alert('hello');
}
var data = {
"text": "Click here",
"func": "tmpCallback()"
};
$('body').append(template(data));
This is just a hack for quick workaround, and I think answer by @BFil may be a better one.