Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Dynamically insert thumbnail item at 0-index position doesn't update all style after listview refresh #1394

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/jquery.mobile.listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
$list.addClass( "ui-listview-inset ui-corner-all ui-shadow" );
}

this._itemApply( $list, $list );
this._itemApply( $list, $list.find("li") );

this.refresh( true );

Expand All @@ -44,7 +44,7 @@ $.widget( "mobile.listview", $.mobile.widget, {

item.find( "p, dl" ).addClass( "ui-li-desc" );

$list.find( "li" ).find( ">img:eq(0), >:first>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
item.find( "img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
$( this ).closest( "li" ).addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
});

Expand Down
69 changes: 69 additions & 0 deletions tests/functional/dynamicInsetList.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Mobile: Grid Layout</title>
<link rel="stylesheet" href="../../themes/default/" />
<link rel="stylesheet" href="../../docs/_assets/css/jqm-docs.css" />
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/"></script>

<script>
$('#jqm-home').live('pagebeforeshow', function(event, ui){
tpl = '<li role="option" id="option%s"><a href="#">';
tpl += '<img src="../../docs/lists/images/%img"/>';
tpl += '<h3>Option %s</h3>';
tpl += '<p>Option %s</p></a></li>';

$('#test').prepend(tpl.replace(/%s/g, '0.5').replace(/%img/g, 'album-bb.jpg'));
$('#option2').before(tpl.replace(/%s/g, '1.5').replace(/%img/g, 'album-p.jpg'));
$('#option2').after(tpl.replace(/%s/g, '2.5').replace(/%img/g, 'album-ws.jpg'));
$('#test').append(tpl.replace(/%s/g, '3.5').replace(/%img/g, 'album-xx.jpg'));
$('#test').listview("refresh");

$("li").bind("tap click", function(e){
$(this).remove();
$("#log")
.prepend("<li>"+ e.type +" event; target: "+ e.target.nodeName +"; message: grid '"+$(this).text()+"' hidden</li>")
.listview("refresh");
}).bind("tap click", false);
});
</script>
</head>
<body>
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="header">
<h1>Dynamic Inset List</h1>
</div>

<div data-role="content">
<p>Touch events on this page will log out below, prepending to the top as they arrive.</p>

<p>Option *.5s are dynamicly inserted when 'pagebeforeshow' event invoked. Click options to remove it.</p>

<ul data-role="listview" data-inset="true" id="test">
<li role="option" id="option1"><a href="#">
<img src="../../docs/lists/images/album-hc.jpg" />
<h3>Option 1</h3>
<p>Option 1</p>
</a></li>
<li role="option" id="option2"><a href="#">
<img src="../../docs/lists/images/album-ok.jpg" />
<h3>Option 2</h3>
<p>Option 2</p>
</a></li>
<li role="option" id="option3"><a href="#">
<img src="../../docs/lists/images/album-rh.jpg" />
<h3>Option 3</h3>
<p>Option 3</p>
</a></li>
</ul>

<ul data-role="listview" id="log">

</ul>

</div>
</div>
</body>
</html>