【问题标题】:Dynamically added page in JQuery is not updating my page with the new styleJQuery 中动态添加的页面未使用新样式更新我的页面
【发布时间】:2017-04-06 16:20:04
【问题描述】:

我创建了一个动态生成并将其添加到 HTML 正文中的函数。但是,它似乎没有用我想要的样式更新。我知道动态添加的内容可能不会继承样式,因此在我的列表视图中我调用了 listview("refresh)。这次我添加了一个 div。我尝试添加 .page() 和其他解决方案,但它们都不是为我工作。正在寻找解决方案。

function pageGenerator() {
  var strings = "<div data-role='page' id = 'page" + currentId + "' align = 'center' style='background-color: #3e99ff;'><div data-role='main' id = 'content" + currentId + "' class='ui-content'><h1 style='color:#ffffff; text-align:center; font-size: 34px; font-family: 'Quicksand', sans-serif !important;'>" + ArrayIndex[currentId] + "</h1></div><div data-role='footer' data-id='foo1' data-position='fixed'><div data-role='navbar'><ul><li><a href='#welcomescreen'>Home</a></li><li><a href='#about'>About</a></li></ul></div></div></div>";
  $("#page_body").append(strings);
// Move to this page by ID '#page'
  $.mobile.changePage("#page" + currentId);
  console.log(1);
  console.log(2);

}

【问题讨论】:

标签: javascript jquery css cordova jquery-mobile


【解决方案1】:

$.mobile.initializePage(); 之间缺少:

$("#page_body").append(strings);$.mobile.changePage("#page" + currentId);

请检查以下stackOverflow answer。你会发现同样的问题和解决方案;)

【讨论】:

  • 你能提供一个结构的示例jsFiddle吗?:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-21
  • 2012-05-20
  • 2017-11-23
  • 1970-01-01
相关资源
最近更新 更多