2

This is the original code

$(this).slideUp(deleteElement);
itemRemove();

The above code calls itemRemove() before the slideUp is complete. So I used callback function as below

$(this).slideUp( deleteElement, function() {
    itemRemove();
});

But this affects the indexing functionality of the repeater(does not decrement the repeater name indexes as the original repeater.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Joyston
  • 806
  • 8
  • 10
  • It's not animation. Ihave to to execute the function itemRemove() only after slideUP is complete @headmax – Joyston Oct 25 '17 at 05:50
  • Can you add the repeater code(Indexing term) also if possible. As of now call back function is the only suitable solution which doesn't fit the scenario – Krishna9960 Oct 25 '17 at 06:22
  • Using default indexing code by initialising data-repeater-list in the div @Krishna9960 – Joyston Oct 25 '17 at 07:12

2 Answers2

1

Probably not the best way, but this is how I solved my problem:

$(this).slideUp(deleteElement);
setTimeout(function(){ itemRemove(); }, 2000);

This code works because the slideUp is complete before 2 seconds. Would love to find the proper way tho, that is as soon as the slideUp is complete.

Joyston
  • 806
  • 8
  • 10
0

It's an old question but i'm answering it for anyone who is searching for the solution. you can call itemRemove() after slideUp is complete and without affecting repeater indexing. I'm adding confirmation too if you don't need it you can remove it.

hide: function (deleteElement) {
            if (confirm('Are you sure you want to delete this element?')) {
                $(this).slideUp(function () {
                    deleteElement();
                    itemRemove();
                });
            }
        }