简体   繁体   English

如何在iScroll4中同时动态添加和删除元素?

[英]How to dynamically add and remove elements at same time in iScroll4?

I have been using iScroll4 for my work from quiet a time 我一直在安静地使用iScroll4来完成我的工作

Though I am facing an issue using it for a case where along with dynamic addition of elements at one end I also need to remove elements from other end. 虽然我在使用它时面临一个问题,即在一端动态添加元素的情况下,我还需要从另一端移除元素。 As in my work I might have to add a lot of data (which holds images) dynamically but I want to maintain same number of child elements in order to manage the memory/performance issue. 在我的工作中,我可能需要动态添加大量数据(其中包含图像),但我希望保持相同数量的子元素以管理内存/性能问题。 It would of great help if any one can suggest me any approach to do it. 如果任何人可以建议我做任何方法,那将是非常有帮助的。

You need to add or delete the elements from particular container using jquery. 您需要使用jquery添加或删除特定容器中的元素。

And while adding and deleting the contents, you need to refresh the iScroll. 在添加和删除内容时,您需要刷新iScroll。

Say for example you create an iscroll as, 比如你创建一个iscroll as,

var myScroll = new iScroll('scrollwrapper', {   });

Then after ever addition or deletion of scrollwrapper contents, refresh the iScroll, so as to work it properly. 然后在添加或删除scrollwrapper内容之后,刷新iScroll,以便正常工作。

myScroll.refresh();

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

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