Reputation: 45
My HTML is like this
<div id="view-user-body" class="panel-body"
data-update-details-url="/dummyurlupdatedetails"
data-reset-password-url="/dummyurlresetpassword">
</div>
and i want to access these data attributes inside my handlebars template
<div class="button yellow tmargin20 buttonWidth">
<a href="{{data-update-details-url}}" title="Update Details" role="button">Update Details</a>
</div>
<div class="button white tmargin20 buttonWidth">
<a href="{{{data-reset-password-url}}}" title="Reset Password" role="button">Reset Password</a>
</div>
How i access data attribute inside my handlebars template???
Upvotes: 1
Views: 1144
Reputation: 570
Use jQuery's ".attr()"
So like:
$('#view-user-body").attr('data-update-details-url'); // will return "/dymmyurlupdatedetails"
And to set them:
$('#view-user-body").attr('data-update-details-url', 'new text');
Upvotes: 1