列表视图看起来奇怪 - jQuery的 [英] Listview looks weird - jQuery
问题描述
我有一些麻烦我的ListView。
它没有漂亮的外观,jQuery提供,而只是一个普通的名单,我没有任何想法,这会怎么来的。
I'm having some trouble with my ListView. It doesn't have the nice look that jQuery offers, but just a plain list and I don't have any idea how this would come.
这是code(HTML)
This is the code (HTML)
<div data-role="page" id="home">
<div data-role="header">
<h1>Bestelling</h1>
<a class="ui-btn-right" href="#toevoegen">+</a>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" id="bestellingLijst">
<!-- Hier komt de bestelling -->
</ul>
</div>
</div>
这里是code其中我添加了一个新的&LT;立GT;
到ListView
$("#bestellingLijst").append("<li>" + naam + ' - ' + prijs + "</li>");
有人能帮助我吗?
谢谢!
Can anybody help me? Thanks!
推荐答案
解决方案
有时,它使用诺
,使列表视图(刷新)要求
等到追加完成,然后调用成功处理这需要运行刷新
在列表视图
。
Sometimes, its required to use promise
to make listview("refresh")
wait till the append is done, then call a success handler which takes runs the refresh
on the listview
.
$("#bestellingLijst").append("<li>" + naam + ' - ' + prijs + "</li>").promise().done( function(){
$(this).listview('refresh');
});
如果你调用附加在一个循环中,它可能是最好将其存储在一个变量,然后再它全部追加到 #bestellingLijst
:
If you're calling append in a loop, it might be better to store it in a variable first, then append it all into #bestellingLijst
:
var i = 0;
var li = "";
for(; i< array.length; i++)
{
//concat to string
li += "<li>" + naam + ' - ' + prijs + "</li>";
}
$("#bestellingLijst").append(li).promise().done( function(){
$(this).listview('refresh');
});
演示
<大骨节病> http://jsfiddle.net/hungerpain/CdQTW/ 骨节病>
的方法更多信息使用
列表视图(刷新)
listview("refresh")
- 文档:<大骨节病> http://api.jquerymobile.com/listview/#method -refresh 骨节病>
- 做些什么:刷新已
数据角色
设置为<$动态创建UL
S的标记C $ C>列表视图。
- Docs : http://api.jquerymobile.com/listview/#method-refresh
- What it does : refreshes the markup of dynamically created
ul
s which havedata-role
set tolistview
.
诺
promise
- 文档:<大骨节病> http://api.jquery.com/promise/ 大骨节病>
- 做些什么:确保某一个类型绑定到该集合中的所有动作,排队与否,已经完成。
完成
done
- 文档:<大骨节病> http://api.jquery.com/deferred.done/一> 骨节病>
- 它所做的:添加处理程序时,承诺解决被称为
其他
和,我希望你调用此刷新JQM中的这样一个页面事件的方法,如果你在页面加载运行以下命令:
And, I hope you're calling this refresh in a page event method of jQM like this,if you're running this on load of the page :
$(document).on("pageinit", "#home", function () {
//append to ul
//refresh the listview
});
这篇关于列表视图看起来奇怪 - jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!