ionic-ion-autoListDivider
ionic-ion-autoListDivider copied to clipboard
On list refresh
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:
After item was deleted:
Yes I have the same issue. The old headers are not cleared on pull to refresh.
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)
}
}
});
I have this same issue when doing any sort of splice etc for deleting...
save my time :-)
if i insert new item some of header missed and show to merge the items How to avoid this situation
+1
+1
+1
+1
+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..
+1
Thanks for the fix.