简体   繁体   English

第一次加载后如何在KnockoutJs中刷新列表?

[英]How to refresh the list in KnockoutJs after it is loaded first time?

I am displaying data list as shown below: 我正在显示数据列表,如下所示:

<div class="my-table" data-bind="if:(dataList() && dataList().length)">
//render data raw here...

I am new to ko and looking to refresh this list without reloading the page, is this something possible with knockout? 我是ko的新手,并希望在不重新加载页面的情况下刷新此列表,是否可以使用淘汰赛?

I believe i can add new items to the list using something like applyBindingsToNode , but looking for a way to refresh the entire list as there are some refreshed numbers on one of the column. 我相信我可以使用诸如applyBindingsToNode东西将新项目添加到列表中,但是由于其中一个列上有一些刷新的数字,因此正在寻找一种刷新整个列表的方法。

You seem to be unclear on the basics of Observable Arrays . 您似乎对Observable Arrays的基础尚不清楚。

You can assign a new array value to dataList by passing the array as an argument: dataList(['one', 'two', 'three']) ; 您可以通过将数组作为参数传递给dataList新的数组值: dataList(['one', 'two', 'three']) ;

You can modify the contents of dataList using most of the usual array-updating functions: push, pop, shift, unshift, reverse, and sort. 您可以使用大多数常用的数组更新功能来修改dataList的内容:推入,弹出,移位,取消移位,反向和排序。 There are also replace and remove functions, which are not standard array-updating functions. 还有替换和删除功能,它们不是标准的数组更新功能。

Any updates you make to dataList using these methods will be reflected in your view, assuming your commented "render data raw here" section makes use of dataList . 使用这些方法对dataList任何更新将反映在您的视图中,假设您注释的“此处渲染数据”部分使用dataList

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

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