【发布时间】: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);
}
【问题讨论】:
-
附加到
body(页面容器),除非您将page_body指定为页面容器。 stackoverflow.com/a/24173950/1771795 -
我给了我的身体 ID = page_body
标签: javascript jquery css cordova jquery-mobile