我创建了一个动态生成并将其添加到HTML正文中的函数。但是,它似乎并没有更新我想要的样式。我知道动态添加的内容可能不会继承样式,因此在我的listview中我调用了listview(“refresh”)。这次我添加了一个div。我尝试添加.page()和其他解决方案,但它们都不是。工作对我来说要寻找一个解决方案在JQuery中动态添加页面并未使用新样式更新我的页面
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);
}
附加到'body'(Page-container),除非你有'page_body'分配为页面容器。 http://stackoverflow.com/a/24173950/1771795 – Omar
我给我的身体ID = page_body – bryancresswell