是否有一个聚合物dom api方法或其他方法来自动更新重复的模板与附加元素,底层数组是否更新?
Is there a Polymer dom api method or other ways to automatically update the repeated template with additional elements, should the underlying array gets updated?
我有一个动态数组,通过重复的ajax调用更新。这个数组不断改变它的长度(元素根据ajax响应递增地附加或删除)。该数组通过< template is =dom-repeat> 反映在文档中。当底层数组更新时,有没有办法自动更新dom?
I have a dynamic array that gets updated through ajax calls repeatedly. This array keeps changing its length (elements get incrementally appended or removed based on the ajax response). The array is reflected in the document through <template is="dom-repeat">. Is there a way to automatically update the dom when the underlying array gets updated?
目前,我唯一可以看到的方式是
At present, the only ways I can see are
通过使用2,我将无法使用列表中的过渡效果在视图中自动更新。我想要使用这些效果。
By using 2, I will not be able to use the transition effects of the list automatically updating in the view. I want to be able to use these effects.
推荐答案如果用 this.push更新数组('myarray',{item}); 那么这将触发Polymer的绑定观察者。更多信息请参见 https://www.polymer- project/1.0/docs/devguide/properties#array-mutation
If you update the array with this.push('myarray', {item}); then that will trigger Polymer's binding observers. More info is in the documentation at www.polymer-project/1.0/docs/devguide/properties#array-mutation
更多推荐
通过更改底层数组来动态更新dom
发布评论