Scroll position of a jquerymobile collapsible set when expanded

后端 未结 1 827
难免孤独
难免孤独 2021-01-12 13:02

I am using a jQueryMobile (v1.4.0) collapsible set / accordions to display a list of elements and its content as shown in this jsFiddle.

相关标签:
1条回答
  • 2021-01-12 13:39

    Once a collapsible is expanded, retrieve its' .offset().top and $.mobile.silentScroll() to that position.

    $(document).on("expand", "[data-role=collapsible]", function () {
      var position = $(this).offset().top;
      $.mobile.silentScroll(position);
    });
    

    Update: For jQuery Mobile 1.4, use collapsibleexpand event.

    Demo - jQM 1.0 - 1.1

    Demo - jQM 1.2 - 1.3

    Demo - jQM 1.4

    0 讨论(0)
提交回复
热议问题