JavaScript-How do I fix an issue where dynamically inserted elements in a iscroll.js scroll container can't be scrolled?

Source: Internet
Author: User
Directly written in the HTML content can scroll, with JS dynamically inserted HTML structure can not scroll, what is going on?

Reply content:

Directly written in the HTML content can scroll, with JS dynamically inserted HTML structure can not scroll, what is going on?

The Iscroll object has a method called Refresh (), which is called after inserting the HTML.

Hello landlord, I have encountered this problem before, you only need to first HTML structure with JS Insert page and then instantiate Iscroll on it, hope can help you!

like this   $('#cart-pop').html(str);   stateMap.myScroll3 = new IScroll('#wrapper-cart', { mouseWheel: true, click: true,probeType: 2});

This occurs because the scroller height is not fixed when initializing Iscroll. You can initialize the Iscroll after you have loaded your DOM. For example, the Iscroll initialization method is written in the Ajax success function.

Just let Iscroll calculate the height again.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.