ionic-ion-autoListDivider icon indicating copy to clipboard operation
ionic-ion-autoListDivider copied to clipboard

On list refresh

Open freekrai opened this issue 10 years ago • 12 comments

If you have set up your list to let you delete items from it, I've found that when the list is refreshed, the items appear at the top and then the letters appear at the bottom.

Before item was deleted:

screenshot 2015-02-22 20 06 31

After item was deleted:

screenshot 2015-02-22 20 06 40

freekrai avatar Feb 23 '15 04:02 freekrai

Yes I have the same issue. The old headers are not cleared on pull to refresh.

scotthooker avatar Feb 26 '15 21:02 scotthooker

I have added a few lines to remove the dividers from list which is enough for my app.

angular.module('ionic.ion.autoListDivider',[])

.directive('autoListDivider', function($timeout) {
var lastDivideKey = "";

return {
    link: function(scope, element, attrs) {
        var key = attrs.autoListDividerValue;

        var dividers = document.getElementsByClassName("item-divider");

        while(dividers.length > 0)
        {
            dividers[0].parentNode.removeChild(dividers[0]);
        }

        var defaultDivideFunction = function(k){
            return k.slice( 0, 1 ).toUpperCase();
        }

        var doDivide = function(){
            var divideFunction = scope.$apply(attrs.autoListDividerFunction) || defaultDivideFunction;
            var divideKey = divideFunction(key);

            if(divideKey != lastDivideKey) { 
                var contentTr = angular.element("<div class='item item-divider'>"+divideKey+"</div>");
                element[0].parentNode.insertBefore(contentTr[0], element[0]);
            }

            lastDivideKey = divideKey;
        }

        $timeout(doDivide,0)
    }
}

});

yang-zhang-syd avatar Apr 18 '15 13:04 yang-zhang-syd

I have this same issue when doing any sort of splice etc for deleting...

Taylorsuk avatar Apr 25 '15 16:04 Taylorsuk

save my time :-)

itrunks avatar Aug 05 '15 08:08 itrunks

if i insert new item some of header missed and show to merge the items How to avoid this situation

itrunks avatar Aug 05 '15 08:08 itrunks

+1

giorgiofellipe avatar Aug 18 '15 20:08 giorgiofellipe

+1

junerockwell avatar Oct 23 '15 17:10 junerockwell

+1

shashu10 avatar Oct 29 '15 23:10 shashu10

+1

joubo avatar Nov 21 '15 10:11 joubo

+1 Same bug when I bind a filter on the ng-repeat. (Looks like the link function triggers only when items appear but never when items are filtered..) I think that issue comes from the angular core..

Nyl000 avatar Apr 17 '16 14:04 Nyl000

+1

jeandat avatar May 01 '16 19:05 jeandat

Thanks for the fix.

mavericks065 avatar Jul 15 '16 04:07 mavericks065