JQuery Mobile默认数据主题

Ren*_*ino 21 javascript mobile themes jquery-mobile

有谁知道如何为jquery-mobile 设置默认数据主题?

看起来有必要为每个组件设置数据主题.

即使为页面数据角色设置了数据主题,加载列表和其他组件也不会遵守它.

我错过了手册的某些页面吗?

Sma*_*tti 30

像Joel说的那样,你必须覆盖默认值.目前似乎没有别的办法.

以Joel的示例代码为例:

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
Run Code Online (Sandbox Code Playgroud)

自定义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...";
});
Run Code Online (Sandbox Code Playgroud)

还应该有其他选项,如:

$.mobile.dialog.prototype.options.theme
$.mobile.selectmenu.prototype.options.menuPageTheme
$.mobile.selectmenu.prototype.options.overlayTheme
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到更多设置:http: //code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js


jBe*_*eas 9

对于嵌套列表视图,要控制标题主题,您需要覆盖将嵌套标题主题设置为蓝色的默认选项.

要执行此操作,只需在jquery loading和jquery.mobile.js loading之间添加以下内容即可.

例:

由于mobileinit事件在执行时会立即触发,因此您需要在加载jQuery Mobile之前绑定事件处理程序.因此,我们建议按以下顺序链接到您的JavaScript文件:

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
Run Code Online (Sandbox Code Playgroud)

所以在"custom-scripting.js"中提出以下内容......

$(document).bind("mobileinit", function () {
   $.mobile.listview.prototype.options.headerTheme = "a";
});
Run Code Online (Sandbox Code Playgroud)

"a"是您希望应用于嵌套标题的主题.

或者您可以在jquery移动源中覆盖它,搜索"headerTheme"它将在5020行附近


Phi*_*ord 7

主题a,b,c,d和e都在css文件中,如果你想要一个自定义主题你可以使用fz,复制并将其更改为你的主题字母.将data-theme ="z"添加到元素中

<body> 
<div data-role="page" id="apply" data-theme="z">
...
</div>
</body>
Run Code Online (Sandbox Code Playgroud)


nau*_*tur 1

据我所知,您必须为页面 div 设置主题,并且它将在内部继承。