开发者

Image in jQuery Mobile back button doesn't appear

I've set-up jQueryMobile plugin into my blog mobile version by the instruction of jQueryMobile documentation.

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>

and description page is as follow

<!DOCTYPE html> 
<html> 
    <head>
    <meta charset="utf-8" /> 
    <title>Against All Odds</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" /> 
    <link rel="stylesheet" href="_assets/css/jqm-docs.css"/>
    <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
</head> 

<body> 

<div data-role="page">
    <div data-role="header">
        <h1>my title</h1>
    </div><!-- /header -->
    开发者_JS百科<div data-role="content">
            my description
    </div><!-- /content -->
</div><!-- /page -->

</body>
</html>

Unfortunately, the image in back button doesn't appear in my page. And I've also put jQuerymobile images folder into my project page. Is there any configuration did I forget to setup?

Image in jQuery Mobile back button doesn't appear


You should check http://jquerymobile.com/download/ and the zip file at the end of the page.

The zip file contains the images directory.

You have to place the images directory in the same directory as your jquery mobile css file.


I was looking through this code yesterday, but instead of looking at the Alpha 2 release (from Nov 12, 2010), I went out to the jquery-mobile page on GitHub and got the master branch download.zip.

The code below is what adds the back button to the header and auto sets the data-icon to arrow-l. I had also forgot to put the images directory in my project.

// auto-add back btn on pages beyond first view
if ( o.addBackBtn && role === "header" &&
        ($.mobile.urlHistory.getPrev() || $(".ui-page").length > 1) &&
        !leftbtn && $this.data( "backbtn" ) !== false ) {

    $( "<a href='#' class='ui-btn-left' data-icon='arrow-l'>"+ o.backBtnText +"</a>" )
        .click(function() {
            history.back();
            return false;
        })
        .prependTo( $this );
}

I also needed to include these js and css files, which I copied from the download into the root directory of my project.

<link rel="stylesheet" href="jquery.mobile.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.mobile.js"></script>


data-icon="arrow-l" is needed in the back button. I'm not sure how they make it the default for auto-generated back button ojn jquerymobile.com docs pages. Looking into it. Come back later.

Also - you shouldn't copy the jqm-docs.css

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜