0

I am developing an application using worklight framework from IBM in which I use jquery mobile library to code.

Unfortunately, when I use $.mobile.silentScroll to scroll, it has no effect, it does not work.

Has anyone met that issue? In other work, How to scroll page in worklight?

1 Answers1

0

I don't think you can do this with jQuery Mobile's silentScroll, as it basically uses window.scrollTo, and this allows to scroll only within the current viewport (what you currently see on the screen).

Instead I would recommend to use iScroll's various API methods: scrollTo, ScrollToElement or Snap, etc.

I tested the below in Android and it worked.
You'll of course need to adjust it to your application...

common\js\main.js:

var myScroll;

function wlCommonInit(){
    myScroll = new IScroll('#wrapper');
}

common\index.html:

<body style="display: none;">
        <div id="wrapper">
            <div data-role="page" id="page">
                <div data-role="content" id="content" style="padding: 15px">                
                    <div id="firstDiv">
                        <input type="button" value="scroll to the other div" onclick="myScroll.scrollToElement('#secondDiv', '0s');"/>
                    </div>
                    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
                    <div id="secondDiv">
                        hello
                    </div>
                </div>
            </div>
        </div>
        ...
        ...
</body>

0s means there will be no scroll effect; it will essentially 'jump' to the desired location.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89