KnockoutJS 可使用 Foreach 进行排序的 Knockout
KnockoutJS Knockout Sortable with Foreach
我想知道 Comment Format Foreach 是否适用于 Knockout Sortable。
我有以下代码结构
<div>
<!-- ko foreach: Countries-->
<div>
<div>
<div class="icon-delete"><img></div>
<div data-bind="text: CountryName"></div>
</div>
</div>
<!-- /ko -->
</div>
我尝试用 sortable 替换 foreach 但它不起作用。
您不能将无容器控制流语法与 sortable
一起使用。来自他们的 github
You cannot use containerless bindings (comment-based) bindings at the top-level of your template, as the jQuery draggable/sortable functionality needs an element to operate on.
因此,您需要使用包装器元素。
我想知道 Comment Format Foreach 是否适用于 Knockout Sortable。
我有以下代码结构
<div>
<!-- ko foreach: Countries-->
<div>
<div>
<div class="icon-delete"><img></div>
<div data-bind="text: CountryName"></div>
</div>
</div>
<!-- /ko -->
</div>
我尝试用 sortable 替换 foreach 但它不起作用。
您不能将无容器控制流语法与 sortable
一起使用。来自他们的 github
You cannot use containerless bindings (comment-based) bindings at the top-level of your template, as the jQuery draggable/sortable functionality needs an element to operate on.
因此,您需要使用包装器元素。