Javascript jquerymobile不';t使用.html()解释插入的代码
当我使用Javascript jquerymobile不';t使用.html()解释插入的代码,javascript,jquery,html,jquery-mobile,click,Javascript,Jquery,Html,Jquery Mobile,Click,当我使用click()和html()更改页面中的内容时,jquery mobile不会更改插入代码的视图,在本例中是listview 我构建了一个简短的示例来说明我的意思: 当您使用Suchen按钮时,它会插入列表,但它看起来不像jquery mobile listview JS: function searchSeries(){ list = '<ul id="seriesResultList" data-role="listview" style="margin-top: 2
click()
和html()
更改页面中的内容时,jquery mobile不会更改插入代码的视图,在本例中是listview
我构建了一个简短的示例来说明我的意思:
当您使用Suchen
按钮时,它会插入列表,但它看起来不像jquery mobile listview
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();
});
});
函数searchSeries(){
list='- /ul>;
$(“#搜索结果”).html(列表);
}
$(文档).ready(函数(){
$(“#提交”)。单击(函数(){
searchSeries();
});
});
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>
系列:
苏晨
您需要触发“创建”事件来创建动态HTML jQM ish
您可以尝试以下方法:
$("#searchResult").trigger('create')
或者如果它不起作用
$(".ui-page").trigger('create')
在包含此元素的页面上。在此处工作正常。您使用的浏览器是什么?
e.preventDefault()可能需要code>停止表单提交
(如果这是您想要的)-检查-