简体   繁体   中英

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"></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.

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