Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for issue #1617: Nested lists with same parent text resolve to th…

…e same sub-page.
  • Loading branch information...
commit 3ee2585cba7f1e1b7cfeb2013a53c318aa00e4f7 1 parent 1449200
@gseguin gseguin authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 js/jquery.mobile.listview.js
View
18 js/jquery.mobile.listview.js
@@ -5,6 +5,10 @@
* http://jquery.org/license
*/
(function($, undefined ) {
+//Keeps track of the number of lists per page UID
+//This allows support for multiple nested list in the same page
+//https://github.com/jquery/jquery-mobile/issues/1617
+var listCountPerPage = {};
$.widget( "mobile.listview", $.mobile.widget, {
options: {
@@ -189,23 +193,31 @@ $.widget( "mobile.listview", $.mobile.widget, {
_idStringEscape: function( str ){
return str.replace(/[^a-zA-Z0-9]/g, '-');
},
-
+
_createSubPages: function() {
var parentList = this.element,
parentPage = parentList.closest( ".ui-page" ),
- parentId = parentPage.jqmData( "url" ),
+ parentUrl = parentPage.jqmData( "url" ),
+ parentId = parentUrl || parentPage[ 0 ][ $.expando ],
+ parentListId = parentList.attr( "id" ),
o = this.options,
dns = "data-" + $.mobile.ns,
self = this,
persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" );
+ if ( typeof( listCountPerPage[ parentId ] ) === 'undefined' ) {
+ listCountPerPage[ parentId ] = -1;
+ }
+ parentListId = parentListId || ++listCountPerPage[ parentId ];
+
$( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) {
var list = $( this ),
+ listId = list.attr( "id" ) || parentListId + "-" + i,
parent = list.parent(),
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),
+ id = ( parentUrl || "" ) + "&" + $.mobile.subPageUrlKey + "=" + listId;
theme = list.jqmData( "theme" ) || o.theme,
countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme,
newPage = list.detach()
Please sign in to comment.
Something went wrong with that request. Please try again.