Skip to content
This repository

Adding items to listviews on a4.1 is too slow #1424

Closed
stickybun opened this Issue April 11, 2011 · 4 comments

3 participants

Alex C Kin Blas CrushYar
Alex C

Adding items, and then refreshing a listview a4.1 on an iPhone4/4.3.1 is too slow. Even since commit 0ef9545
This was not the case on a3.

To recreate click 'double list' button on the following links to double a list of 20, and then 40.
a3: http://jsbin.com/evemo4 takes 113ms, 228ms
a4.1+: http://jsbin.com/exuwe3/2 takes 1700ms, 6460ms

Kin Blas
jblas commented April 11, 2011

Ok, I found the source of the slow down. It's due to this little nugget in listview's _itemApply():

    $list.find( "li" ).find( ">img:eq(0), >:first>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
        $( this ).closest( "li" ).addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
    });

For every list item, we're traversing the entire list to find all the first images of an li. Not really sure what this is about.

Kin Blas
jblas commented April 11, 2011

I'll need to find out if this was what was really meant:

    item.children("img:eq(0)").add(item.children(":first > img:eq(0)")).addClass( "ui-li-thumb" ).each(function() {
        item.addClass( $(this).hasClass("ui-li-icon") ? "ui-li-has-icon" : "ui-li-has-thumb" );
    });

Replacing the code in question with the code above, gets things into the ballpark of 1.0a3.

Kin Blas
jblas commented April 12, 2011

Landed some changes that should make things better:

98dc036

Kin Blas jblas closed this April 12, 2011
CrushYar

I load data for list using ajax and after call listview('refresh'); ui-li-has-icon class not applied for items with
before this cpommit only first item was rendered without ui-li-has-icon

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.