[英]Change the default data-theme from jQuery Mobile
使用jQuery Mobile,我可以使用自定義主題創建頁面
<div data-role="page" data-theme="s" id="home">...
現在這可行,但要求我在每個頁面中添加此行,並且每次添加新頁面。 我嘗試將data-theme="s"
到body標簽,但這沒有任何影響。 有沒有辦法做到這一點,然后每頁手動設置?
你必須以編程方式,AFAIK。
有點像:
$(document).bind( "mobileinit", function ()
{
...
$.mobile.page.prototype.options.contentTheme = "z"; //your theme
...
});
現在,由於沒有集中式掛鈎 - 您必須為所有主題選項執行類似的行:
$.mobile.page.prototype.options.headerTheme
$.mobile.page.prototype.options.footerTheme
等等。
我沒有所有這些列表,但快速查看jquery.mobile-1.0rc1.js搜索.prototype.options.
揭示這些:
$.mobile.page.prototype.options.backBtnTheme
$.mobile.page.prototype.options.headerTheme
$.mobile.page.prototype.options.footerTheme
$.mobile.page.prototype.options.contentTheme
$.mobile.listview.prototype.options.filterTheme
所以在我看來,你可以隨身攜帶這些,並在你去的時候發現更多。 請注意 ,並非所有這些都是這樣創建的 - 有些是在代碼中動態構造的。 尋找Theme
字符串,看看我的意思。
更新
$.mobile.page.prototype.options.theme
應該更新 - 基於Moak的評論如下。
以下對我有用。 只需確保在JQM初始化后調用它。
$.mobile.page.prototype.options.theme = "b";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.