/ / jQuery Mobile Dynamic Content Insertion - jquery, динамічна, jquery-mobile, функція сторінки

Вставка інтерактивного динамічного вмісту jQuery Mobile - jquery, dynamic, jquery-mobile, функція сторінки

Гаразд, хтось допоможе мені з'ясувати, чому "тест" у наступному коді не видно? Я перевірив live dom і, здавалося б, обробляються елементи:

<!DOCTYPE HTML>
<html>
<head>

<!-- Grab Google CDN"s jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script>
$(document).ready(function(){
$("<div data-role="content" class="content"><ul data-role="listview" data-inset="true"><li><a href="#im?at=animals">test</a></li></ul></div>").appendTo("#home").page();
$.mobile.changePage("#home", {transition: "none"});
});
</script>
</head>

<body>
<div id="home" data-role="page">
</div>
</body>
</html>

Заздалегідь спасибі.

Відповіді:

1 для відповіді № 1

Виклик changePage не працює, оскільки у вас є лише одна сторінка, яка за замовчуванням видима / активна. Ви можете змусити активну сторінку оновити, запустивши подія створення.

$("<div data-role="content" class="content"><ul data-role="listview" data-inset="true"><li><a href="#im?at=animals">test</a></li></ul></div>").appendTo("#home");
$.mobile.changePage("#home", {transition: "none"});
$.mobile.activePage.trigger("create");

0 для відповіді № 2

Елемент нижче має display властивість встановлена ​​на none і це приховує своїх братів і сестер:

<div data-role="content" class="content ui-page ui-body-c ui-content" tabindex="0" role="main">

Правило CSS:

.ui-mobile [data-role="page"], .ui-mobile [data-role="dialog"], .ui-page {
top: 0;
left: 0;
width: 100%;
min-height: 100%;
position: absolute;
display: none;
border: 0;
}