3

I have a searchresults.php page which shows several users that have been found. Also on the searchresults.php page is a panel

<div data-role="panel" id="mypanel" data-display="overlay" data-theme="a">
  <div id="loadedprofile">
  </div>
</div><!-- /panel -->

When I click on one of the "user divs" the following Jquery function fires to open the panel:

a panel on select of a search result.

The JQuery code:

$('[id=profile]').on("click", function(e) {

    e.preventDefault();
    var userid = $(this).attr('userid');
    //window.location.href = "userdetails.php?userid=" + userid;

    $("#mypanel").panel("open");
    $("#loadedprofile").load("userdetailspanel.php?userid=" + userid);

    $("#mypanel").trigger("updatelayout");

    $('#commandlist').listview('refresh');

    $('[data-role=page]').trigger('pagecreate');
    $.mobile.activePage.trigger('pagecreate');

    $('#commandlist').listview().listview('refresh');

});

Ok, so the panel opens up correctly and the dynamic page (userdetailspanel.php) is loaded correctly (see image). But ALSO on the userdetailspanel.php is a listview.

<ul data-role="listview" data-inset="true" id="commandlist">
 <li>
  <a href="#" id="mylink" name="mylink" >
    <img src='bolt.png' class="ui-li-icon" />Link
  </a>
 </li>
</ul>

This listview is not rendered correctly. I just see blue hyperlinks.

Listview issie

4

2 回答 2

3

将项目动态附加到面板后,调用.trigger('pagecreate');

$('[data-role=page]').trigger('pagecreate');

或者

$.mobile.activePage.trigger('pagecreate');

演示- jQM 1.3.2 及以下


对于 jQuery Mobile v 1.4,它是不同的

$('.target').trigger('create')

演示- jQM v 1.4 Aplha

于 2013-08-29T15:55:07.173 回答
3

好的,所以诀窍是在 userdetailspanel 部分的底部添加刷新。

因此,在 UL 之后,添加:

<script type="text/javascript">
       $('#commandlist').listview().listview('refresh');
</script>
于 2013-08-30T07:57:22.157 回答