Template.someTemplate.events({
'click': function () {
if (isTemplateName() === 'template1') {
// do something
}
if (isTemplateName() === 'template2') {
// do something
}
if (isTemplateName() === 'template3') {
// do something
}
}
});
is there built in function for isTemplateName() ā¦?? or any way to create isTemplateName() functionā¦??
This would not work, because someTemplate must be equal to either template1, template2 or template3. Maybe you assumed that a template file is a template. But this is not the case. A template is always created by one single <template> tag, so you actually have 3 templates here, plus an event helper for a fourth template called someTemplate.
EDIT: Ok, I think I got what you are trying to achieve. Instead of checking the template name, you can pass additional data to someTemplate like this:
Did not know that, may come in handy in certain cases. But it would not help here, I suppose, since @karina wanted the name of the parent template. Is it possible to get this somehow, too?