Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

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

Closed
phillpafford opened this issue Sep 27, 2012 · 2 comments
Closed

Comments

@phillpafford
Copy link

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

@alzoid
Copy link

alzoid commented Sep 27, 2012

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.

alzoid added a commit to alzoid/jquery-mobile that referenced this issue Sep 28, 2012
jquery-archive#5098 dynamic Nested lists with same parent text resolve to the sam

Listview: added check for exisintg list when adding nested lists. Fixed
jquery-archive#5098 dynamic Nested lists with same parent text resolve to the same
sub-page
@jaspermdegroot
Copy link
Contributor

Closing as won't fix. See #5657.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants