0

Hi i am using this kill function in my application, here I am calling kill function inside a for loop each time it will return d for each iteration

but some times I am getting d value before it is completion of d.done() and after returning d it is calling d.done() could any body please suggest me which concept i have to use here

kill: function() {
    var t = this
    ,   url = "My URL"//App.Data.url('user', p.get('id'), 'dissociate_tag', id)
    ,   d = _.http.del(url);

    d.done(function() {
        t.resetTile();
        t.set('killed', true);
    });

    return d;
}
prudvi raju
  • 505
  • 1
  • 5
  • 19

1 Answers1

0

you give done a callback method, which is called when it's finished, d will likely always be returned before the method passed into done is called.

The trick is to have the code that calls kill wait on d to complete (if it's important that it's finished before it continues)

Kingpin2k
  • 47,277
  • 10
  • 78
  • 96