Find Model in Backbone

29 views Asked by At

I am trying to find a model object from backbone.

For this I have made a method which is calling in loop and passing id to this method.

initializeRepairOrder: (id) ->
  @repair_order = App.Models.RepairOrder.find({ id: id })
  if _.isEqual(@repair_order, null)
    @repair_order = new App.Models.RepairOrder({ id: id })
    @repair_order.fetch({ async: false })

I am calling this method in loop. Let's suppose we have 4 id's in our array so this method will call four times. So issue is first 3 times if will go to if 'condition', but last time it will get repair_order from find.

Not understanding why this is happening for last element.

0

There are 0 answers