admin管理员组文章数量:1290978
With jQuery Mobile I can create a page using a custom theme
<div data-role="page" data-theme="s" id="home">...
Now this works, but requires that I add this line in each of my pages and every-time I add a new page. I tried adding data-theme="s"
to the body tag but this has no affect. Is there any way to do this other then setting it manually per page?
With jQuery Mobile I can create a page using a custom theme
<div data-role="page" data-theme="s" id="home">...
Now this works, but requires that I add this line in each of my pages and every-time I add a new page. I tried adding data-theme="s"
to the body tag but this has no affect. Is there any way to do this other then setting it manually per page?
2 Answers
Reset to default 8You would have to do it programmatically, AFAIK.
Something along the lines of:
$(document).bind( "mobileinit", function ()
{
...
$.mobile.page.prototype.options.contentTheme = "z"; //your theme
...
});
Now, since there is no centralized hook - you will have to do the similar line for all theme options there are:
$.mobile.page.prototype.options.headerTheme
$.mobile.page.prototype.options.footerTheme
and so on.
I don't have a list of all of them, but a quick look through the jquery.mobile-1.0rc1.js searching for .prototype.options.
reveals these:
$.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
so it seems to me that you can go with these and discover more as you go. Note that not all of them are created like that - some are constructed dynamically in the code. Look for Theme
string to see what I mean.
Update
$.mobile.page.prototype.options.theme
should be updated as well - based on Moak's ment below.
The following worked for me. Just make sure it's called after JQM is initialized.
$.mobile.page.prototype.options.theme = "b";
本文标签: javascriptChange the default datatheme from jQuery MobileStack Overflow
版权声明:本文标题:javascript - Change the default data-theme from jQuery Mobile - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741519610a2383101.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论