i want change div
in template programatically can't work. there way using helper function?
template.home.helpers({ jcropdiv: function() { var div = ''; if(roles.userisinrole(meteor.user(), ['admin'])){ div = '<div id="jcrop_target">'; } else { div = '<div class="jcrop-holder" style="background-color: black; height: 719px; width: 1280px; position: relative;">'; } return div; } });
i not believe can write tags dynamically, can add attributes tag dynamically. example:
<div {{jcropdiv}}> stuff </div> template.home.helpers({ jcropdiv: function() { var tags; if(roles.userisinrole(meteor.user(), ['admin'])){ tags = 'id="jcrop_target"'; } else { tags = 'class="jcrop-holder" style="background-color: black; height: 719px; width: 1280px; position: relative;"'; } return tags; } });
that should return either id="jcrop_target"
or 'class="jcrop-holder" style="background-color: black; height: 719px; width: 1280px; position: relative;"'
based on if user in 'admin' role.
Comments
Post a Comment