[英]jquery mobile doesn't interpret my inserted code with .html()
when I change the content in my page using click()
and than html()
, jquery mobile doesn't change the view of the inserted code, in this case a listview. 当我使用
click()
和html()
更改页面中的内容时,jquery mobile不会更改插入代码的视图,在本例中为listview。
I build a shortened example to show what I mean: 我构建了一个缩短的例子来说明我的意思:
http://jsfiddle.net/eTz8H/ http://jsfiddle.net/eTz8H/
When you use the Suchen
button it insert the list, but it don't looks like the jquery mobile listview. 当您使用
Suchen
按钮时,它会插入列表,但它看起来不像jquery移动列表视图。
JS: JS:
function searchSeries(){
list = '<ul id="seriesResultList" data-role="listview" style="margin-top: 2em;" data-inset="true"><li><a href="#"><img src="http://www.tvdb.info/gfx/v/v20703.gif"><h2>Vegas</h2><p>USA 2012–</p></a></li></ul>';
$("#searchResult").html(list);
}
$(document).ready(function() {
$("#submit").click(function(){
searchSeries();
});
});
HTML HTML
<form class="ui-body ui-body-a" id="seriesNew" action="index.php?site=autoseriesNew" method="post" style="padding-bottom: 2em;">
<label for="newSerie">Serie:</label>
<input type="search" name="newSerie" id="newSerie" value="">
<button class="ui-shadow ui-btn ui-corner-all" type="submit" id="submit">Suchen</button>
</form>
<div id="searchResult">
</div>
You will need to trigger 'create' event for making dynamic HTML jQM-ish. 您需要触发'create'事件来制作动态HTML jQM-ish。
You can try with the following, 你可以试试以下,
$("#searchResult").trigger('create')
or if it doesn't work, 或者如果它不起作用,
$(".ui-page").trigger('create')
on the page containing this element. 在包含此元素的页面上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.