借助 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
...
});
现在,由于没有集中 Hook - 您必须对所有主题选项执行类似的操作:
$.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
也应该更新 - 基于下面莫克的评论。
关于javascript - 从 jQuery Mobile 更改默认数据主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7924665/