列表视图看起来奇怪 - jQuery的 [英] Listview looks weird - jQuery

查看:133
本文介绍了列表视图看起来奇怪 - 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")

  • Docs : http://api.jquerymobile.com/listview/#method-refresh
  • What it does : refreshes the markup of dynamically created uls which have data-role set to listview.

promise


  • 文档:<大骨节病> http://api.jquery.com/promise/

  • 做些什么:确保某一个类型绑定到该集合中的所有动作,排队与否,已经完成。

完成

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆