2015-04-23 91 views
0

編輯jQuery Mobile的 - 持久性工具欄與後退按鈕

搗鼓這個問題的:https://jsfiddle.net/9k449qs2/ - 調試小提琴,儘量選擇與您的選擇器的標題。您無法這樣做,每次點擊時都會選擇整個頁面。


我只是在一個具有持久性頁眉和頁腳的項目上工作。只需點擊應用程序即可更改內容。現在,我想一個後退按鈕添加到我做了與標題:標題後直接

<header id="headerMain" data-position="fixed" data-role="header"> 
    <a href="#" data-rel="back"> 
     <div class="backButton">GO BACK</div> 
    </a> 
</header> 

我的代碼的其餘部分是這樣的:

<div data-role="page" id="pageMain"> 
    <div class="content gray"> 
     <a href="#checkConnection">adfjsöalfjasödf</a> 
    </div> 
</div><!-- pageMain end --> 

<footer id="footerMain" data-position="fixed" data-role="footer"> 
    Footer 
</footer> 


<div data-role="page" id="checkConnection"> 
    <div class="content gray"> 
     <button id="checkConnectionState" class="button" onclick="CTFNetworkState()">Check your Connection</button> 
     <a href="#checkBattery"> 
      <button id="checkBatteryState" class="button">Check your Battery</button> 
     </a> 
    </div> 
</div> <!-- checkConnection end --> 

<div data-role="page" id="checkBattery"> 
    <div class="content gray"> 
     <p>Just plug your device and you'll get information about your battery state.</p> 
    </div> 
</div> <!-- checkBattery end --> 

所以一切工作正常,過渡和等等。但我無法得到後臺工作。他不可點擊。每個頁面上的標題不能以任何形式點擊。如果我使用gapDebug進行調試,並且點擊標題,GapDebug標記Pagecontainer而不是標題。

那麼,怎樣才能使我在每一頁上的標題點擊裏面的後退按鈕?

編輯

所以頭並不關心,我把什麼樣的按鈕裏面。無論我選擇哪個按鈕,或者我添加到我的<a></a>的哪個屬性都無法點擊。 所以我試圖再次運行GapDebug,按「檢查」按鈕,比我後退按鈕點擊,這點我從哪個是錯誤頁面的代碼。 enter image description here

+1

好吧,嘗試刪除HREF和數據的rel = 「後面」,把的onclick = 「history.go(-1);」而不是 – AmmarCSE

+0

不起作用。我認爲這對按鈕上的正確命令沒有問題,對於應用於每個頁面的持久性標題看起來更像是一個問題。在GapDebug中,它看起來像標題不在正確的圖層上。 我有一個返回按鈕,intergrated進入內容領域,是一個正常工作與「數據的rel =」後面「」 – Sithys

+0

我只是增加了一個小提琴阿馬爾 - 後退按鈕的內容是點擊,後退按鈕在頭不是。 – Sithys

回答

0

所以我找到了解決辦法。問題在於,持久工具欄的文檔不是幫助我的,而是外部工具欄的文檔。

只需添加

$(function(){ 
    $("[data-role='header'], [data-role='footer']").toolbar(); 
}); 

<script></script>標籤內,一切工作正常。出現這種情況Because these toolbars are not within the page they will not auto initalize. You must call the toolbar plugin yourself.