[英]JQuery Mobile default data-theme
有誰知道如何為jquery-mobile設置默認數據主題?
看起來有必要為每個組件設置數據主題。
即使為頁面數據角色設置了數據主題,加載列表和其他組件也不會遵守它。
我錯過了手冊的某些頁面嗎?
像Joel說的那樣,你必須覆蓋默認值。 目前似乎沒有別的辦法。
以Joel的示例代碼為例:
<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
自定義custom-scripting.js
這是一個示例代碼,您可以配置更多選項:
$(document).bind("mobileinit", function () {
// Navigation
$.mobile.page.prototype.options.backBtnText = "Go back";
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnTheme = "d";
// Page
$.mobile.page.prototype.options.headerTheme = "a"; // Page header only
$.mobile.page.prototype.options.contentTheme = "c";
$.mobile.page.prototype.options.footerTheme = "a";
// Listviews
$.mobile.listview.prototype.options.headerTheme = "a"; // Header for nested lists
$.mobile.listview.prototype.options.theme = "c"; // List items / content
$.mobile.listview.prototype.options.dividerTheme = "d"; // List divider
$.mobile.listview.prototype.options.splitTheme = "c";
$.mobile.listview.prototype.options.countTheme = "c";
$.mobile.listview.prototype.options.filterTheme = "c";
$.mobile.listview.prototype.options.filterPlaceholder = "Filter data...";
});
還應該有其他選項,如:
$.mobile.dialog.prototype.options.theme
$.mobile.selectmenu.prototype.options.menuPageTheme
$.mobile.selectmenu.prototype.options.overlayTheme
您可以在此處找到更多設置: http : //code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js
對於嵌套列表視圖,要控制標題主題,您需要覆蓋將嵌套標題主題設置為藍色的默認選項。
要執行此操作,只需在jquery loading和jquery.mobile.js loading之間添加以下內容即可。
例:
由於mobileinit事件在執行時會立即觸發,因此您需要在加載jQuery Mobile之前綁定事件處理程序。 因此,我們建議按以下順序鏈接到您的JavaScript文件:
<script src="jquery.js"></script> <script src="custom-scripting.js"></script> <script src="jquery-mobile.js"></script>
所以在“custom-scripting.js”中提出以下內容......
$(document).bind("mobileinit", function () {
$.mobile.listview.prototype.options.headerTheme = "a";
});
“a”是您希望應用於嵌套標題的主題。
或者您可以在jquery移動源中覆蓋它,搜索“headerTheme”它將在5020行附近
主題a,b,c,d和e都在css文件中,如果你想要一個自定義主題你可以使用fz,復制並將其更改為你的主題字母。 將data-theme =“z”添加到元素中
<body>
<div data-role="page" id="apply" data-theme="z">
...
</div>
</body>
據我所知,你必須為頁面div設置一個主題,它將在內部繼承。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.