Is it possible to pass a variable called "templateBody" into a function in this code snippet?
function GetMenu(){
var templates = [{name:"maher",body:"<p>Maher test</p>"},{name:"Jeremy",body:"<p>Jeremy test</p>"}]
var payload = []
for (var i = 0; i<templates.length; i++){
var templateBody = templates[i].body
payload.push({
text : templates[i].name,
onclick: function(templateBody){tinymce.activeEditor.execCommand('mceInsertContent', false, templateBody);}
})
}
return payload
}