【发布时间】:2011-02-03 21:24:30
【问题描述】:
有人知道如何为 jquery-mobile 设置 默认 数据主题吗?
看起来有必要为每个组件设置数据主题。
即使您为页面数据角色设置数据主题,加载的列表和其他组件也不会尊重它。
我错过了手册的某些页面吗?
【问题讨论】:
标签: javascript mobile themes jquery-mobile
有人知道如何为 jquery-mobile 设置 默认 数据主题吗?
看起来有必要为每个组件设置数据主题。
即使您为页面数据角色设置数据主题,加载的列表和其他组件也不会尊重它。
我错过了手册的某些页面吗?
【问题讨论】:
标签: javascript mobile themes jquery-mobile
就像 Joel 所说,您必须覆盖默认值。目前看来没有别的办法了。
以 Joel 的示例代码为例:
<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
自定义您的 custom-scripting.js
这是一个示例代码,您可以配置更多选项:
$(document).bind("mobileinit", function () {
// Navigation
$.mobile.page.prototype.options.backBtnText = "Go back";
$.mobile.page.prototype.options.addBackBtn = true;
$.mobile.page.prototype.options.backBtnTheme = "d";
// Page
$.mobile.page.prototype.options.headerTheme = "a"; // Page header only
$.mobile.page.prototype.options.contentTheme = "c";
$.mobile.page.prototype.options.footerTheme = "a";
// Listviews
$.mobile.listview.prototype.options.headerTheme = "a"; // Header for nested lists
$.mobile.listview.prototype.options.theme = "c"; // List items / content
$.mobile.listview.prototype.options.dividerTheme = "d"; // List divider
$.mobile.listview.prototype.options.splitTheme = "c";
$.mobile.listview.prototype.options.countTheme = "c";
$.mobile.listview.prototype.options.filterTheme = "c";
$.mobile.listview.prototype.options.filterPlaceholder = "Filter data...";
});
还应该有其他选项,例如:
$.mobile.dialog.prototype.options.theme
$.mobile.selectmenu.prototype.options.menuPageTheme
$.mobile.selectmenu.prototype.options.overlayTheme
您或许可以在此处找到更多设置: http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js
【讨论】:
对于嵌套列表视图,要控制标题主题,您需要覆盖将嵌套标题主题设置为蓝色的默认选项。
为此,您只需在 jquery 加载和 jquery.mobile.js 加载之间添加以下内容。
示例:
因为 mobileinit 事件在执行时立即触发, 您需要在加载 jQuery Mobile 之前绑定您的事件处理程序。 因此,我们建议在以下链接到您的 JavaScript 文件 顺序:
<script src="jquery.js"></script> <script src="custom-scripting.js"></script> <script src="jquery-mobile.js"></script>
所以在“custom-scripting.js”中加入以下内容...
$(document).bind("mobileinit", function () {
$.mobile.listview.prototype.options.headerTheme = "a";
});
其中“a”是您要应用于嵌套标题的主题..
或者您可以在 jquery 移动源中覆盖它,搜索“headerTheme”它将在第 5020 行附近
【讨论】:
主题 a,b,c,d 和 e 都在 css 文件中,如果您想要自定义主题可以使用 f-z,复制 a 并将其更改为您的主题字母。将 data-theme="z" 添加到您的元素中
<body>
<div data-role="page" id="apply" data-theme="z">
...
</div>
</body>
【讨论】:
据我所知,您必须为页面 div 设置一个主题,并且它将在内部继承。
【讨论】: