2013-07-03 77 views
-1

我試圖從jQuery Mobile開始,但當我試圖用疊加幻燈片創建左面板時,我卡住了。這裏是我的代碼:jQuery Mobile創建面板

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>- test-</title> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"> </script> 
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script> 
</head> 
<body> 
    <div data-role="page"> 
    <div data-role="panel" id="testPanel" data-theme="e" data-position="left" data-display="overlay"> 
    <h3>Default panel options</h3> 
    <p>This panel has all the default options: positioned on the left with the reveal display mode. The panel markup is <em>before</em> the header, content and footer in the source order.</p> 
    <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p> 
</div> 
<div data-role="header"> 
    <h1>test</h1> 
    <a href="#testPanel" data-role="button" data-icon="plus" data-iconpos="notext">Contact</a> 
</div> 
<div data-role="content"> 
</div> 
<div data-role="footer" data-position="fixed"> 
    <h4>Copyright 2013 - All Rights Reserved -</h4> 
</div> 
</div> 
</body> 
</html> 

它不工作,當我點擊我的鏈接按鈕,我有這樣的消息「錯誤加載頁面」我的面板的內容在頁面已顯示。謝謝你的幫助!

回答

2

好像您正在使用jQueryjQuery Mobile框架的過期版本。我會建議更新到最新版本。

這裏有一個working demo與使用jQuery 1.9.1和jQuery移動1.3.1

+0

感謝隊友,它肯定現在的作品! –

1

如果這不是你的索引頁,那麼你最有可能在這種情況下,通過<a href="yourpage.html>Page</a>找到它jquery使用Ajax請求從一個頁面導航到另一個頁面,ajax請求不加載頁面的全部內容,它只加載<body>標籤的內容,即您在<head>標籤內寫入的任何腳本都不會被加載,因此頁面將無法正常工作,您將面臨錯誤 解決此問題您需要使用data-ajax="false"裏面的<a>屬性來防止jquery mobile使用Ajax調用來加載你的頁面。

,如果它是你的索引頁,然後請過去的js代碼,所以我們可以檢查它在所有情況下 檢查這些鏈接 for loading jqm pages而這個鏈接problem of ajax call in jqm

+0

非常感謝,對於像我這樣的初學者來說,這非常有用!歡呼; D –

+0

不客氣 –