Created
February 12, 2011 12:56
-
-
Save medovob/823744 to your computer and use it in GitHub Desktop.
Enable SubPages from listview in jQuery Mobile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('div').live('pagebeforecreate', function(event, ui) { | |
var subpageIndex = 0, | |
$page = $(this), | |
pageURL = $page.data("url"), | |
$body = $page.parent(); | |
$page.find("ul[data-role='listview']>li>[data-role='subpage']").each(function() { | |
var $subcontent = $(this), | |
$li = $subcontent.parent(), | |
$ul = $li.parent(), | |
subpageURL = pageURL+"?subpage="+(subpageIndex++), | |
$subpage = $('<div data-role="pending-page"></div>').attr("data-url",subpageURL).appendTo($body), | |
$titleElement = $li.find("[data-role='subpagetitle']"), | |
title = $titleElement.length ? $titleElement.text() : $page.find("[data-role='header'] h1").text(), | |
$aTarget = $titleElement.length ? $titleElement.eq(0) : $li.children().eq(0), | |
$subpageHeader = $('<div data-role="header"></div>').append($('<h1/>').text(title)).appendTo($subpage); | |
$subcontent.attr("data-role","content").appendTo($subpage); | |
$aTarget.wrapInner('<a></a>'); | |
$a = $li.find("a:eq(0)").attr("href",subpageURL); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment