mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-04 20:54:46 +00:00
Fixed up nested listviews so that any markup that comes before the child list will be used for complex formatting in the list item node. Text nodes that are direct children of the LI still work fine as well. Fixes #585
This commit is contained in:
parent
4011cf684e
commit
b0eb2bd053
2 changed files with 17 additions and 17 deletions
|
|
@ -22,10 +22,9 @@
|
|||
<div data-role="content">
|
||||
<ul data-role="listview">
|
||||
<li>
|
||||
<a href="#">
|
||||
<h3>Animals</h3>
|
||||
<p>All your favorites from aarkvarks to zebras.</p>
|
||||
</a>
|
||||
<h3>Animals</h3>
|
||||
<p>All your favorites from aarkvarks to zebras.</p>
|
||||
|
||||
<ul>
|
||||
<li>Pets
|
||||
<ul>
|
||||
|
|
@ -72,10 +71,10 @@
|
|||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<h3>Colors</h3>
|
||||
<p>Fresh colors from the magic rainbow.</p>
|
||||
</a>
|
||||
|
||||
<h3>Colors</h3>
|
||||
<p>Fresh colors from the magic rainbow.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="index.html">Blue</a></li>
|
||||
<li><a href="index.html">Green</a></li>
|
||||
|
|
@ -87,10 +86,9 @@
|
|||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<h3>Vehicles</h3>
|
||||
<p>Everything from cars to planes.</p>
|
||||
</a>
|
||||
<h3>Vehicles</h3>
|
||||
<p>Everything from cars to planes.</p>
|
||||
|
||||
<ul>
|
||||
<li>Cars
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -295,27 +295,29 @@ $.widget( "mobile.listview", $.mobile.widget, {
|
|||
self = this,
|
||||
persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" );
|
||||
|
||||
$( parentList.find( "ul, ol" ).toArray().reverse() ).each(function( i ) {
|
||||
$( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) {
|
||||
var list = $( this ),
|
||||
parent = list.parent(),
|
||||
title = $.trim(parent.contents()[ 0 ].nodeValue) || parent.find('a:first').text(),
|
||||
nodeEls = $( list.prevAll().toArray().reverse() ),
|
||||
nodeEls = nodeEls.length ? nodeEls : $( "<span>" + $.trim(parent.contents()[ 0 ].nodeValue) + "</span>" ),
|
||||
title = nodeEls.first().text(),//url limits to first 30 chars of text
|
||||
id = parentId + "&" + $.mobile.subPageUrlKey + "=" + self._idStringEscape(title + " " + i),
|
||||
theme = list.jqmData( "theme" ) || o.theme,
|
||||
countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme,
|
||||
newPage = list.wrap( "<div data-" + $.mobile.ns + "role='page'><div data-" + $.mobile.ns + "role='content'></div></div>" )
|
||||
.parent()
|
||||
.before( "<div data-" + $.mobile.ns + "role='header' data-" + $.mobile.ns + "theme='" + o.headerTheme + "'><div class='ui-title'>" + title + "</div></div>" )
|
||||
.before( "<div data-" + $.mobile.ns + "role='header' data-" + $.mobile.ns + "theme='" + o.headerTheme + "'><div class='ui-title'>" + title + "</div></div>" )
|
||||
.after( persistentFooterID ? $( "<div data-" + $.mobile.ns + "role='footer' data-" + $.mobile.ns + "id='"+ persistentFooterID +"'>") : "" )
|
||||
.parent()
|
||||
.attr( "data-" + $.mobile.ns + "url", id )
|
||||
.attr( "data-" + $.mobile.ns + "theme", theme )
|
||||
.attr( "data-" + $.mobile.ns + "count-theme", countTheme )
|
||||
.appendTo( $.mobile.pageContainer );
|
||||
|
||||
|
||||
newPage.page();
|
||||
var anchor = parent.find('a:first');
|
||||
if (!anchor.length) {
|
||||
anchor = $("<a></a>").html(title).prependTo(parent.empty());
|
||||
anchor = $("<a></a>").html( nodeEls || title ).prependTo(parent.empty());
|
||||
}
|
||||
anchor.attr('href','#' + id);
|
||||
}).listview();
|
||||
|
|
|
|||
Loading…
Reference in a new issue