在追加()listview Javascript之后丢失了JQuery Mobile CSS样式

时间:2013-07-02 20:39:21

标签: javascript listview append refresh jquery-mobile

我知道之前已经问过这个问题,但我已经尝试了所有可以找到的解决方案,但无济于事。

我的jqm样式没有初始化,非常像这个人的问题:JQuery mobile -> .append() removes CSS? 我已经尝试了.trigger('create')和listview('refresh')方法,甚至是两者的组合。

玉:

    #category(data-role='page')
      a(href='#automobile', data-transition='slide', onclick="return loadItemsBrief('automobile');")
          | Automobile
    ... //code reduced here
    #automobile(data-role='page')
     div(data-role='content')
       div#refresh(data-role='fieldcontain')
         ul#autoList(data-role='listview', data-divider-theme='b', data-inset='true')

Javascript(单独的.js)

    function loadItemsBrief(cat){ 
     $.getJSON(''+cat, function (json) {
      $.each(json.items,function(i,data) {
       $('#autoList').append('<li data-theme="c"><a href="" data-transition="slide" class="touchableButton"><div style="display: inline-block"><img style="width: 100px; height: 125px" src=""'+data.fileUrls[0]+'></div><div style="display: inline-block"><h3>Title: '+data.name+'</h3><h3>Price: '+data.minBid+'</h3><h3>Condition: '+data.condition+'</h3></div></a></li>'); //tried .trigger('create') here
      });
      $('#autoList').listview('refresh'); //also tried placing .listview('refresh') in inner most layer
     });
    }

firebug给我的错误是:

TypeError: $(...).listview is not a function
$("#autoList").listview("refresh");

非常感谢帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

显然,在尝试了所有可能的解决方案之后,我尝试将我的JQuery版本更改为1.8.3,并将我的JQM版本保留为1.3.1。现在所有列表视图都按照正常情况刷新。