Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created August 26, 2012 19:49
Show Gist options
  • Save rtekie/3483076 to your computer and use it in GitHub Desktop.
Save rtekie/3483076 to your computer and use it in GitHub Desktop.
// Display a list of urls you want to share.
function showUrlList(urlObj, options) {
// Get list of urls
var myUrls = getMyUrls();
// Get the page we are going to write our content into.
var $page = $("#home");
// Get the content area element for the page.
var $content = $page.children(":jqmData(role=content)");
// Build the list of urls.
var markup = "<ul data-role='listview'>";
for (var i=0; i<myUrls.length; i++) {
markup = markup + "<li><a href='#qrcode?url=" + myUrls[i] + "'>" + getHostname(myUrls[i]) + "</a></li>";
}
markup = markup + "</ul>";
// Inject the list markup into the content element.
$content.html(markup);
// Pages are lazily enhanced. We call page() on the page
// element to make sure it is always enhanced before we
// attempt to enhance the listview markup we just injected.
$page.page();
// Enhance the listview we just injected.
$content.find( ":jqmData(role=listview)" ).listview();
// Now call changePage() and tell it to switch to the page we just modified.
$.mobile.changePage($page, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment