Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6942391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:00:37+00:00 2026-05-27T13:00:37+00:00

I keep reading about the Backbone.js zombie (or memory leak) problem. Basically you have

  • 0

I keep reading about the Backbone.js zombie (or memory leak) problem. Basically you have to unbind and remove the element from the DOM when you no longer need it to make sure all events are removed as well.

Now, I have a single page app with a few containers:

<div id="page1"></div>
<div id="page2"></div>

and add my underscore.js templates to these placeholders. I have a model per page like:

HomeView = Backbone.View.extend({
  el: '#page1'
)}

Now, when I click on an element on that page I navigate to another Backbone.js view:

clicked: function(ev){
  $(this.el).remove(); // <-- this is the problem
  $(this.el).unbind();
  App.navigate('page/2', true);
}

This works fine but… I removed the page1 element from the DOM so when I use the back button to go to the previous page my element is gone and there is nothing to attach the HTML to.

I probably don’t understand how to link Backbone.js views with the DOM… should I keep the element with the risk of memory leaks?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:00:38+00:00Added an answer on May 27, 2026 at 1:00 pm

    As the article says, (yes, I’ve tried his methods before in my own projects), you have to find a way to remove your view’s DOM element and unbind the events.
    There are, however, 2 types of events, 1) Backbone events, 2) the events that are bound to your DOM elements with jQuery.

    So instead of your:

    $(this.el).remove();
    $(this.el).unbind();
    

    Do this:

    this.remove();
    this.unbind();
    

    You are now removing Backbone events as well; and the this.remove on a view will call $(this.el).remove();.

    However, that is only how to remove a view and not leave zombies. You should consider his methods for showing a view to make this process more automatic.
    This is all in his article.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep reading about how great this new Canvas element for HTML5 is and
I keep reading about C99 and C++11 and all these totally sweet things that
I keep reading about people who are test infected, meaning that they don't just
I keep reading about defficiencies and issues with languages. Specifically, I'm learning PHP and
I keep reading that an ASP.NET based web site should have custom errors enabled
I keep reading about how biased locking, using the flag -XX:+UseBiasedLocking , can improve
I keep reading about the importance of vectorized functionality so hopefully someone can help
One of the benefits of ASP.NET MVC I keep reading about is that it's
I've been reading about layout optimization from the Android Dev blogs and I've been
I keep reading about html helpers for images and a lot of other useful

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.