开发者

jquery minScrollBack: 'infinity' not working

The page still automatically scrolls to the last position even after applying the override. I'm i not doing it correctly or what?

<link rel="stylesheet" href="css/jquery.mobile-1.0b1.css" />
<link rel="stylesheet" href="css/jquery.mobile.datebox.css" />
<script type="text/javascript" charset="utf-8" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"><开发者_StackOverflow社区/script>
<script type="text/javascript" charset="utf-8">
     $(document).bind("mobileinit", function(){ //jquery mobile override
    $.extend(  $.mobile , {
      minScrollBack:'infinity'

      });
    });
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.mobile-1.0b1.js"></script>
<script type="text/javascript" charset="utf-8" src="js/custom.js"></script>


http://jsfiddle.net/puUan/1/

This jsfiddle shows how the .ui-title class set the focus to the top of the page.

<h1 class="ui-title">title page 1</h1>

should work. What happens is this: on page transition (or some such event) jQuery calls a function named reFocus() that looks like:

//direct focus to the page title, or otherwise first focusable element
function reFocus( page ) {
    var lastClicked = page.jqmData( "lastClicked" );

    if( lastClicked && lastClicked.length ) {
        lastClicked.focus();
    }
    else {
        var pageTitle = page.find( ".ui-title:eq(0)" );
        if( pageTitle.length ) {
           pageTitle.focus();
        }
        else{
            page.find( focusable ).eq( 0 ).focus();
        }
    }
}

the line: page.find( focusable ).eq( 0 ).focus(); is probably focusing on a link you've clicked.

Alternative:-

comment out this call in transistionPages(

reFocus( toPage ); 

to:

//reFocus( toPage ); 

This will stop the function getting called altogether, (I personally don't see a reason for it.) but if you are using the jQuery Mobile from a CDN that probably not possible.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜