2012-04-04 49 views
12

我有,我不想風格在特定頁面一個JQM應用程序。如何從造型頁面停止JQM?

我到目前爲止發現的所有內容都是data-role='none' - 但我不想將它應用於頁面上的每個元素......如果關閉此頁面,是否有辦法關閉?

回答

15

您可以使用data-enhance="false"$.mobile.ignoreContentEnabled=true一起停止自動增強功能,jQuery Mobile的確實給僞頁:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" /> 
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 
<script> 
$(document).on('mobileinit', function() { 
    $.mobile.ignoreContentEnabled = true; 
}); 
</script> 
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script> 

<div data-enhance="false" data-role="page"> 
    ... 
</div>​ 

你必須改變ignoreContentEnabled標誌,因爲它是CPU密集型的緣故爲data-attribute搜索父元素,所以這是默認截止。

這裏是一個演示:http://jsfiddle.net/ZtJyL/1/

4

正如我已經指出here,你也可以使用官方的,theme-less version of the CSS內置了專門允許自定義主題的設計。

根據我的經驗,使用像data-enhance="false"data-role="none"這樣的黑客常常會使用結構化,非專題的CSS來破解內容。

有了這個方法,你可以把所有jQuery Mobile的基本功能,你不必與黑客戰鬥和覆蓋所有的時間,你會得到一個打火機CSS作爲獎金。

+0

非常感謝哥們! – Skamielina 2015-08-24 12:26:21