简体   繁体   English

访问把手模板中的数据属性值

[英]Access data attribute value inside handlebars template

My HTML is like this 我的HTML就是这样

<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??? 我如何访问车把模板中的数据属性???

Use jQuery's ".attr()" 使用jQuery的“ .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'); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM