JQuery 中动态添加的页面未使用新样式更新我的页面

Dynamically added page in JQuery is not updating my page with the new style

我创建了一个动态生成并将其添加到 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);

}

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

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

请检查以下内容Whosebug answer。您会发现同样的问题及其解决方案 ;)