JQM (jQueryMobile) Problem with AJAX content and focus()

╄→尐↘猪︶ㄣ 提交于 2019-12-11 03:59:51

问题


I'm using the Multi-page layout (Example), in my case the second page content is being generated by an AJAX call.

My problem is I have the AJAX call(s) to get the next/previous page and load the content (This is working), But some of the content is very long and the user will have to scroll to the top of the page to press/click the next/previous page button(s).

NOTE: I have the next/previous buttons on the top and the bottom of the page

What I would like is if the user clicks the next/previous button to set focus to the top of the page, so if the content page is very large it would start from the top instead of the user scrolling back to the top of the page.

Here is the example/question for my AJAX code

Another problem is in using JQM the anchor hashes <a href='#' are used for page transitions


回答1:


You probably want to bind to the event generated after $.mobile.changePage() and have it scroll to the top of the document.




回答2:


$.mobile.silentScroll(0);

http://jquerymobile.com/test/docs/api/events.html#../../docs/api/methods.html



来源:https://stackoverflow.com/questions/5409543/jqm-jquerymobile-problem-with-ajax-content-and-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!