jQuery Mobile的.listview('刷新')不工作 [英] jQuery Mobile .listview('refresh') not working

查看:111
本文介绍了jQuery Mobile的.listview('刷新')不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我建设使用jQuery Mobile移动网络应用程序,我有一个问题。我使用jQuery来解析XML文件,并创建列表项。它建立的名单,然后apppends李的的该列表给UL在页面上。我看书上说,为了得到列表中正确的风格,你必须调用.listview(刷新)后,您将数据追加刷新列表,以便jQuery Mobile的可以设置正确的造型到列表中。

So, i'm building a mobile web app with jQuery Mobile and i am having a problem. I am using jQuery to parse an xml file and create list items. It builds the list, then apppends that list of LI's to the UL on the page. I read that in order to get the list to be styled correctly you have to call .listview('refresh') after you append the data to refresh the list so that the jQuery Mobile can set correct styling to the list.

我的问题是该列表从未刷新。它不断得到称呼不正确。难道我做错了什么?难道我的code正确吗?仅供参考,我已经试过各种.listview(),.listview(刷新)等的变化

My problem is that the list never refreshes. It keeps getting styled incorrectly. Am i doing anything wrong? Is my code correct? FYI, i have tried all kinds of variations of .listview(), .listview('refresh'), etc.

code:

<script type="text/javascript">
        $(window).load(function(){
            $.ajax({
                type: "GET",
                url: "podcast.xml",
                dataType: "xml",
                async: false,
                success: parseXml
            });
        });
        function parseXml(xml){
            var podcastList = "";
            $(xml).find("item").each(function(){
                podcastList += "<li class='ui-li-has-thumb ui-btn ui-btn-icon-right ui-li ui-btn-up-c' role='option' data-theme='c'><img src='" + $(this).find("itunes\\:image").attr("href") + "' class='ui-li-thumb'><h3 class='ui-li-heading'><a href='" + $(this).find("enclosure").attr("url") + "' class='ui-link-inherit'>" + $(this).find("title").text() + "</a></h3><p class='ui-li-desc'>" + $(this).find("itunes\\:subtitle").text() + "</p></li>";
            });
            $("#podcastList").append(podcastList);
            $("#podcastList").listview('refresh');
        }
    </script>

谢谢!

推荐答案

我就遇到了这个问题,code寻找与你相似。我的解决办法是刷新放入$就完成选项。

I ran into this problem with code looking similar to yours. My solution was to place the refresh into the $.ajax "complete" option.

        complete: function() {
            $('#list-id').listview('refresh');
        } 

这篇关于jQuery Mobile的.listview('刷新')不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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