2011-01-12 70 views
1

我已经通过jQueryMobile文档的指示将jQueryMobile插件设置到了我的博客移动版本中。jQuery Mobile中的图像后退按钮不会出现

<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> 

和描述页面如下

<!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 --> 
    <div data-role="content"> 
      my description 
    </div><!-- /content --> 
</div><!-- /page --> 

</body> 
</html> 

不幸的是,在后退按钮图像不会出现在我的网页。我还将jQuerymobile图像文件夹放入我的项目页面。有没有我忘记安装的配置?

alt text

回答

2

昨天我正在查看这段代码,但没有看到Alpha 2版本(从2010年11月12日),我去了GitHub上的jquery-mobile页面,并得到了主分支download.zip

下面的代码是将后退按钮添加到标题并自动将data-icon设置为arrow-l。我也忘了把图像目录放在我的项目中。

// 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); 
} 

我还需要包含这些js和css文件,我将它们从下载文件复制到我的项目的根目录中。

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

投给你和正确的答案。我昨天下载了Alpha 2并已经测试过了。奇怪的是,如后退按钮中显示的箭头那样正常。 – ppshein

0

data-icon="arrow-l"需要在返回按钮。我不确定他们是如何使它成为自动生成的后退按钮ojn jquerymobile.com文档页面的默认值。看着它。晚一点回来。

而且 - 你不应该在页面的末尾复制JQM-docs.css

+0

没有。后退按钮由jQueryMobile自动生成。我已经查看了文档页面中的Back按钮。但是,还没有得到任何答案。 – ppshein

+0

是的,我知道它是生成的。但不知何故,在jquerymobile上的文档和演示中,它获得了data-icon属性,当我使用它时 - 它不会。 – naugtur

3

您应该检查http://jquerymobile.com/download/和zip文件。

该zip文件包含images目录。

您必须将images目录放置在与jquery mobile css文件相同的目录中。

+0

当然,我已经把Images文件夹放在与CSS文件相同的目录中。但它不行, – ppshein

相关问题