Skip to content

Instantly share code, notes, and snippets.

@efeminella
Created March 11, 2012 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efeminella/2015388 to your computer and use it in GitHub Desktop.
Save efeminella/2015388 to your computer and use it in GitHub Desktop.
Refresh jQuery Mobile listview
var list = "";
var items = [
{name: "Item A", url: "/#item-a"}
, {name: "Item B", url: "/#item-b"}
, {name: "Item C", url: "/#item-c"}
];
$.each( items, function(i, item) {
list += '<li><a href="' + item.url + '">';
list += item.name;
list += '</a></li>';
});
// .listview('refresh') will ensure the list markup enhancements
// and associated styles are applied as expected...
$("ul:jqmData(role='listview')").append( list ).listview("refresh");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment