繁体   English   中英

从jQuery Mobile更改默认数据主题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM