0

From what I have read http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/ and Backbone.js : repopulate or recreate the view? I learned that hidden view should be unbind'ed from events.

How about removing a model? After calling

  • remove() on Collection
  • destroy() on the Model
  • remove() on View

Shall I call off() on Model as the last step?

Assuming no one else hold a reference to the instance of the model, is that the end of zombie killing? The view might still have a reference to the model, should the view's this.model set to null?

Anymore memory leak?

Thank you

Community
  • 1
  • 1
Henry
  • 32,689
  • 19
  • 120
  • 221

1 Answers1

4

Read the annoted source , it's pretty clear what model.destroy() does , it doesnt delete the model , just request the server to delete a REST resource. if you want to get rid of the model in your script you can create a destroy function to your view that will erase any objects you want to get rid of.

http://documentcloud.github.com/backbone/docs/backbone.html

regarding events , i'm not sure , but yeah you could call off , you could also spy the internal event object of the model in your browser dev tools to see if it still exists after you delete the model.

mpm
  • 20,148
  • 7
  • 50
  • 55
  • how do I "spy the internal event object"? Say, Chrome or FF? – Henry Jun 02 '12 at 01:15
  • 1
    put a breakpoint after the model is created , and you should be able to watch the event object in Chrome for instance , go to the script tab , there is a watch menu where you can add spies. – mpm Jun 02 '12 at 01:22