Skip to content
This repository

dynamic Nested lists with same parent text resolve to the same sub-page #5098

Closed
phillpafford opened this Issue · 2 comments

3 participants

Phill Pafford Allan Jasper de Groot
Phill Pafford

Related to:

JS Fiddle:

StackOverFlow:

When appending the li element dynamically the sub-page indices are incorrect. It duplicates the indices starting over at 0 instead of using the next incremented index. This causes the original page with index 0 and the new page with index 0 to display as active and stack over one another

Allan

I have done some research and found that _createSubPages does not count if there are already items in the list you are adding to.

I added the 2 variables :

parentLength,childLength

and set them as follows

parentLength = parentList.find( "li>ul, li>ol" ).toArray().length;
childLength = $( parentList ).children("li").length;

$( parentList.find( "li>ul, li>ol" ).toArray().reverse() ).each(function( i ) { 
//this is the build loop
//.
//removed code for simplicity
//.
//on this line i added
listId = list.attr( "id" ) || parentListId + "-" + (parentLength<childLength?childLength-parentLength:i),

}

And that fixed the problem. I think there are issues when adding to a nested list as well which I am investigating. I am new to the jquery mobile project so I don;t know if my code is inline with your standards, maybe a someone with more project knowledge could verify this fix.

Allan alzoid referenced this issue from a commit in alzoid/jquery-mobile
Allan alzoid Listview: added check for exisintg list when adding nested lists. Fixed
#5098 dynamic Nested lists with same parent text resolve to the sam

Listview: added check for exisintg list when adding nested lists. Fixed
#5098 dynamic Nested lists with same parent text resolve to the same
sub-page
6c4acb7
Jasper de Groot
Collaborator

Closing as won't fix. See #5657.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.