當前位置:編程學習大全網 - 源碼下載 - 使用jqueryMobile怎麽分頁

使用jqueryMobile怎麽分頁

剛開始項目只是選擇了iscroll框架實現滾動翻頁,後來和jQuery mobile(jqm)框架整合後,界面沒法使用

在網上搜索了很多資料,各種嘗試後還是問題很多。最後在老外的網站上發現了jquery-mobile-iscrollview框架,用於整合jquery mobile和iscroll的壹個開源框架,處理了很多jquery mobile和iscroll整合中出現的問題。

1、jquery-mobile-iscrollview下載地址:/watusi/jquery-mobile-iscrollview

解壓後的\jquery-mobile-iscrollview-master\jquery-mobile-iscrollview-master\demo\source路徑下是需要引用的js和css文件

\jquery-mobile-iscrollview-master\jquery-mobile-iscrollview-master\demo\build路徑下是各個jquery mobile版本下的列表和滾動翻頁的例子

在該路徑下,我選擇了pull_14.html文件,用chrome打開後,發現下面的導航欄變形,將

<link href="stylesheets/demo.css" media="screen" rel="stylesheet" type="text/css" />

<script src="javascripts/demo.js" type="text/JavaScript"></script>

去掉後,下面的導航欄正常了

頁面中引用的pull-example.js文件是上拉、下拉事件的處理,只需要將gotPullDownData和gotPullUpData函數修改壹下即可實現自己需要加載的數據

2、直接測試該功能沒有什麽問題,當把該翻頁的頁面鏈接到其他頁面上時,通過鏈接打開該頁面,下面的導航欄又出現了問題

後來發現,這是問題可能是由於jqm的外部頁面鏈接引起的錯。jqm在使用外部鏈接打開另壹個頁面時,會使用ajax讀取需要打開的文件,然後將該文件動態加載到已經打開的頁面的後面,jqm只加載文檔中取出的第壹個頁面(第壹個帶有role="page"的div),其他內容都將被忽略。

後來,將列表頁面(b.html)所有加載的css和js的標簽放到鏈接該頁面的頁面(a.html)的<head>標簽中。

[html] view plain copy

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="viewport"

content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />

<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<link rel="stylesheet" href="../jquery.mobile-1.4.2.min.css" type="text/css">

<link href="../jquery.mobile.iscrollview.css" media="screen"

rel="stylesheet" type="text/css" />

<link href="../jquery.mobile.iscrollview-pull.css"

media="screen" rel="stylesheet" type="text/css" />

<script src="../jquery.js" type="text/javascript"></script>

<script>

$(document).bind("mobileinit", function(){

//容許ajax跨域訪問

$.mobile.allowCrossDomainPages = true;

});

</script>

<script src="../jquery.mobile-1.4.2.min.js"

type="text/javascript"></script>

<script src="../javascripts/iscroll.js" type="text/javascript"></script>

<script src="../javascripts/jquery.mobile.iscrollview.js"

type="text/javascript"></script>

<script src="../javascripts/pull-example.js" type="text/javascript"></script>

當鏈接打開該頁面後,列表頁面穩定了

3、jquery-mobile-iscrollview中引用的jqm框架的版本沒有項目中的高,試著將jqm的版本替換為項目中使用的版本後,該功能依舊沒有出現問題

  • 上一篇:24849976@qq.com求應急預案
  • 下一篇:如何在angularjs中使用highcharts
  • copyright 2024編程學習大全網