Home > Backend Development > PHP Tutorial > javascript - How to solve the problem that dynamically inserted elements in iscroll.js scrolling container cannot be scrolled?

javascript - How to solve the problem that dynamically inserted elements in iscroll.js scrolling container cannot be scrolled?

WBOY
Release: 2016-07-06 13:53:27
Original
1577 people have browsed it

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?

Reply content:

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template