简体   繁体   中英

JQuery mobile bug with scrollTop

In the following link I have attached a sample of my source code:

http://jsfiddle.net/xY7tx/2381/

I have a list of 34 items when you press down the keyboard and you reach the 10th item, it would successfully scrollTop to 11th element. But when you keep pressing down and when you reach 20th item, with my code it supposed to scrollTop to 21th item but it isn't.

To reproduce the bug please keep pressing down on keyboard and pay attention to the 20th ---> 21th item which is not desirable (and compare it with 10th --> 11th item change which is desirable).

If i have done any mistake, my apologies and please show me in the source code what change should I make so that in change of 20th to 21th item, it would scrollTop as well. Thanks!

Edit: Thanks to ezanker. with his answer , i can now scrollTop to the item of 21th , but still there is a problem when i want to scrollTop t the 31th item , still it isn't working with the current code . please keep pressing down on keyboard until 31th item , you would see the problem.

The problem is that you are setting

var container = $('div'),

but jQuery Mobile automatically creates a page div to wrap around your code if you do not explicitely provide the div. Change it to

var container = $('#listAddr'),

Updated FIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM