Ajax 刷新列表视图问题

Ajax 刷新列表视图问题,ajax,listview,jquery-mobile,refresh,Ajax,Listview,Jquery Mobile,Refresh,我对刷新listview有问题 我在同一个html文件中有两个页面。 在这两个页面中,我都使用Ajax动态生成了一个listview: <ul data-role="listview" data-filter="true" id="nestedList"> </ul> 对于第一页,一切正常。 在第二个页面中,我添加了一个简单的脚本,可以动态刷新: <script> $('ul#secondList').listview("refresh"); </s

我对刷新listview有问题

我在同一个html文件中有两个页面。 在这两个页面中,我都使用Ajax动态生成了一个listview:

<ul data-role="listview" data-filter="true" id="nestedList">
</ul>
对于第一页,一切正常。 在第二个页面中,我添加了一个简单的脚本,可以动态刷新:

<script>
 $('ul#secondList').listview("refresh");
</script>

$('ul#secondList')。列表视图(“刷新”);
有了jQueryMobile Beta1,我可以回到第一页,一切都还可以。 使用jQueryMobile Beta2,当我返回到第一页时,listview是空的

我试图添加相同的“脚本”来动态刷新第一页。它不起作用。当我回到第一页时,“加载”jQuery消息正在发生,并且从未离开

我听说过jQuery Mobile Beta 2的“创建”触发器,但我可能不明白它的真正含义


有解决方案吗?

您需要在live()中执行此操作

例如:

$('#secondList_page_id').live('pageshow',function(event, ui) {
    $('#secondList').html(dynamicSecondList);
    $('ul#secondList').listview("refresh");
});

$('#nestedList_page_id').live('pageshow',function(event, ui) {
    $('#nestedList').html(dynamicNestedList);
    $('ul#nestedList').listview("refresh"); 
});

当我切换到另一个页面时,nestedList内容似乎消失了。当我回来的时候,即使我做了一个列表视图“刷新”,内容也不再在这里了。。。这很奇怪,因为这不会影响第二个列表..它有效。。虽然不如beta1好,但效果很好。更奇怪的是,第二个列表不需要这些代码,内容一旦放进去就留在列表中。。。虽然第一个列表在更改页面时总是丢失其内容…但为了更好地进行调试,您需要添加如何使用DynamicEstedList
<script>
 $('ul#secondList').listview("refresh");
</script>
$('#secondList_page_id').live('pageshow',function(event, ui) {
    $('#secondList').html(dynamicSecondList);
    $('ul#secondList').listview("refresh");
});

$('#nestedList_page_id').live('pageshow',function(event, ui) {
    $('#nestedList').html(dynamicNestedList);
    $('ul#nestedList').listview("refresh"); 
});