简体   繁体   English

在JQMobile中由代码数据主题设置

[英]Set by code data-theme in JQMobile

I have a page created dinnamically with jquery mobile and javascript. 我有一个用jquery mobile和javascript创建的页面。 I am retrieving some data from server with ajax for showing on the page (descriptions, title,..., data-theme). 我正在使用ajax从服务器检索一些数据以显示在页面上(描述,标题,...,数据主题)。

I have created the code of my page in html and in javascript I have something like: 我已经在html和javascript中创建了页面代码,如下所示:

$(document).on('pagebeforecreate', '#descripcion', function (event, ui) {
retrievePoiData();
function retrievePoiData(){
  var jsonFile = '{"poi":"' +  poiID + '"}';
  $.ajax({
          type: "POST",
          url: urlServer+"retrieveData.php",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          data: jsonFile,
          success: function(response) {
                  title = response['title'];
                  latitude = response['coordinates']['lat'];
                  ...

Then, in success function I set all texts and images of my webpage: 然后,在成功功能中,我设置了网页的所有文本和图像:

          document.getElementById("title_poi").innerHTML = title;
          document.getElementById("image_poi").src = imageURL;
          document.getElementById("derecha_poi").innerHTML = description_short;
          document.getElementById("descr_larga_poi").innerHTML = description_long;

And I can see them in my webpage. 我可以在我的网页上看到它们。

But each time I tried to do the same with data-theme, I can't. 但是每次我尝试对数据主题做同样的事情时,我都做不到。 Theme is always "a". 主题始终为“ a”。 I have a css file with lots of characters (a,b,c.....,v). 我有一个css文件,其中包含许多字符(a,b,c .....,v)。 I haven't found in my code any reference to "a" so I don't know why jqm is loading that theme. 我在代码中没有找到对“ a”的引用,所以我不知道jqm为什么要加载该主题。

I just want to set data-theme in data-role header and footer. 我只想在数据角色页眉和页脚中设置数据主题。 Not in more places. 没有更多的地方。 What is the correct way to do it? 正确的方法是什么?

If you need to see more code, just ask. 如果您需要查看更多代码,请询问。

Use .toolbar() method to change theme of header and/or footer. 使用.toolbar()方法更改页眉和/或页脚的主题。

$(".selector").toolbar({
    theme: "b" /* swatch */
});

.selector = [data-role=header] , [data-role=footer] , #id or .class . .selector = [data-role=header][data-role=footer]#id.class

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM