Home >Backend Development >PHP Tutorial >javascript - How to solve the problem that dynamically inserted elements in iscroll.js scrolling container cannot be scrolled?
The content written directly in the html can be scrolled, but the html structure dynamically inserted using js cannot be scrolled. What's going on?
The content written directly in the html can be scrolled, but the html structure dynamically inserted using js cannot be scrolled. What's going on?
The iScroll object has a method called refresh(). You can call this method after inserting html
Hello poster, I have encountered this problem before. You only need to insert the html structure into the page using js and then instantiate iscroll. I hope it can help you!
<code>like this $('#cart-pop').html(str); stateMap.myScroll3 = new IScroll('#wrapper-cart', { mouseWheel: true, click: true,probeType: 2});</code>
This situation is because when initializing iscroll, the scroller height is not fixed. You can initialize iscroll after loading your dom. For example, write the initialization method of iscroll in the success function of ajax.
Just let iscroll recalculate the height