Wednesday, April 2, 2014

Backbone View Event Types

Today I read through Derick Bailey's excellent post on memory management in Backbone view code.  I was a bit confused by all the different ways to register and un-register events and what they were all for.  Specifically I was confused by his close() method, used to clean up view events.

Why was unbind() needed in addition to remove()?   Why was stopListening() not needed?

So I put together a simple guide for myself.

After putting this together the code makes more sense.

You do need to call unbind() in addition to remove() because remove() handles DOM events and unbind() handles Backbone events.

You don't need to call stopListening() because unbind() catches everything stopListening() would catch.  You don't need undelegateEvents() because jquery's remove() removes all of the events on that DOM element for you.

Hope that helps.

4 comments:

  1. Emperor Casino Review - Shootercasino.com
    Emperor Casino has a large number of slot machines and a wide range of games. The selection of games and a variety of 제왕카지노 video slots makes 바카라 the slots exciting 바카라 사이트

    ReplyDelete