diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index 3e5200b0368..de221c4e651 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -277,31 +277,35 @@ $.widget( "mobile.listview", $.mobile.widget, { o = this.options, persistentFooterID = parentPage.find( "[data-role='footer']" ).data( "id" ); - $( parentList.find( "ul, ol" ).toArray().reverse() ).each(function( i ) { - var list = $( this ), - parent = list.parent(), - title = parent.contents()[ 0 ].nodeValue.split("\n")[0], + $( parentList.find( "ul, ol,[data-role='subpage']" ).not("[data-role='subpage'] *").toArray().reverse() ).each(function( i ) { + var content = $( this ), + parent = content.parent(), + titleElement = parent.children("[data-role='subpagetitle']").eq(0).wrapInner(""), + title = titleElement.length ? titleElement.text() : parent.contents()[ 0 ].nodeValue.split("\n")[0], id = parentId + "&" + $.mobile.subPageUrlKey + "=" + $.mobile.idStringEscape(title + " " + i), - theme = list.data( "theme" ) || o.theme, - countTheme = list.data( "counttheme" ) || parentList.data( "counttheme" ) || o.countTheme, - newPage = list.wrap( "
" ) + theme = content.data( "theme" ) || o.theme, + countTheme = content.data( "counttheme" ) || parentList.data( "counttheme" ) || o.countTheme, + newPage = (content.is("[data-role='subpage']") ? content.attr('data-role','content') : $("
").append(content)) + .wrap( "
" ) + .before( "
" + title + "
" ) + .after( persistentFooterID ? $( "
", { "data-role": "footer", "data-id": persistentFooterID, "class": "ui-footer-duplicate" } ) : "" ) .parent() - .before( "
" + title + "
" ) - .after( persistentFooterID ? $( "
", { "data-role": "footer", "data-id": persistentFooterID, "class": "ui-footer-duplicate" } ) : "" ) - .parent() - .attr({ - id: id, - "data-theme": theme, - "data-count-theme": countTheme - }) - .appendTo( $.pageContainer ); + .attr({ + id: id, + "data-theme": theme, + "data-count-theme": countTheme + }) + .appendTo( $.pageContainer ); - - - newPage.page(); + newPage.page(); + + if(titleElement.length==0) { + parent.html("" + title + ""); + } + + parent.find("a:eq(0)").attr("href","#" + id); - parent.html( "" + title + "" ); - }).listview(); + }).filter("ul,ol").listview(); } });