我需要像data-id,data-action
这样的属性<div class="dd" id="nestable3">
<ol class="dd-list">
<li class="dd-item dd3-item" data-id="13">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 13</div>
</li>
<li class="dd-item dd3-item" data-id="14">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 14</div>
</li>
<li class="dd-item dd3-item" data-id="15">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 15</div>
<ol class="dd-list">
<li class="dd-item dd3-item" data-id="16">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 16</div>
</li>
<li class="dd-item dd3-item" data-id="17">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 17</div>
</li>
<li class="dd-item dd3-item" data-id="18">
<div class="dd-handle dd3-handle">Drag</div><div class="dd3-content">Item 18</div>
</li>
</ol>
</li>
</ol>
</div>
我需要创建属性data-id =“13”。 如何使用knockout js attr绑定创建它...
答案 0 :(得分:26)
使用attr绑定data-bind="attr: {'data-id': id}"