开发者

jquery mobile - listview - smooth loading of item details?

I have a list view. When the user clicks on an item, I want to open some details for the item that was clicked. I've got this working, but I'm running into the following problems:

  1. When the user clicks on a list item, the list auto-scrolls to the top before loading the new page. This isn't very smooth... I don't think the list should scroll to the top.

  2. After loading the details and the user clicks the back button, the detail开发者_开发百科s go away and the list is displayed from the top instead of where the list was previously scrolled.

Here's a very simple test page that I'm using:

http://code.redtopia.com/examples/2011-07-07-jquery-listview-details/index.html

NOTE: To load the details, I'm calling a JS function that calls $.mobile.changePage (). I also noticed that you need to add your javascript in the href="" attribute instead of onclick when using the listview, otherwise your JS won't get called (prob. b/c the jqm framework overrides the onclick attribute when list items are linked).


I'm having the same issue. Currently I have a click delegate on each li in the listview that handles the data loading and calls the changepage function.

ETA: I tested this just now, and setting href instead of calling changePage did the following; it's not a perfect solution but it's the best I have at the moment.

  1. The page scrolls to the top (I know, this is what we're trying to avoid, but bear with me).
  2. The page transitions to the detail page.
  3. Upon pressing back, the listview page was at the top, but then scrolled down to the item that was selected.

No, it's not a perfect solution and this may be a JQuery Mobile bug that needs squashing, but (IMO) it's better than not returning to the item selected at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜