I want to show a message when a jQuery mobile ListView has no elements. For example: "There are no elements." How can I do it?
-
A listview that is dynamically generated? or a listview that uses filtering?andleer– andleer2013-01-15 17:58:54 +00:00Commented Jan 15, 2013 at 17:58
-
@andleer a list view that is dynamically generated.Alfredo Osorio– Alfredo Osorio2013-01-15 17:59:40 +00:00Commented Jan 15, 2013 at 17:59
Add a comment
|
2 Answers
If you are dynamically generating your listview and find no rows to display, why not simply display a row with a message stating as much?
<ul data-role="listview" data-inset="true">
<li data-role="list-divider">Results</li>
<li>No records found</li>
</ul>
Comments
Use a popup to show warning:
$('#index').live('pagebeforeshow',function(e,data){
if($('#test-list li').length === 0){
setTimeout(function(){$('#MyFirstPopup').popup('open');},100);
}
});
Here's an working example: http://jsfiddle.net/Gajotres/wy5R3/