更改 jQuery Mobile 的默认数据主题
借助 jQuery Mobile,我可以使用自定义主题创建页面
<div data-role="page" data-theme="s" id="home">...
现在这可以工作,但需要我在每个页面中以及每次添加新页面时添加此行。我尝试将 data-theme="s"
添加到 body 标记,但这没有任何影响。除了每页手动设置之外,还有什么方法可以做到这一点吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AFAIK,你必须以编程方式完成它。
大致如下:
现在,由于没有集中的挂钩 - 您将必须对所有主题选项执行类似的操作:
等等。
我没有所有这些选项的列表,但快速浏览一下 jquery.mobile-1.0rc1.js 搜索
.prototype.options.
就会发现:所以在我看来,你可以跟着这些走,并在走的过程中发现更多。 请注意,并非所有这些都是这样创建的 - 有些是在代码中动态构造的。查找
Theme
字符串即可明白我的意思。更新
$.mobile.page.prototype.options.theme
也应该更新 - 基于 Moak 下面的评论。You would have to do it programmatically, AFAIK.
Something along the lines of:
Now, since there is no centralized hook - you will have to do the similar line for all theme options there are:
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: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 comment below.以下内容对我有用。只需确保在 JQM 初始化后调用它即可。
The following worked for me. Just make sure it's called after JQM is initialized.