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

  • SEARCH
  • Home
  • 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 8427179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:43:20+00:00 2026-06-10T04:43:20+00:00

I just don’t have idea what causes problem and need help. Before posting I’ve

  • 0

I just don’t have idea what causes problem and need help. Before posting I’ve came up to alternative solution, but I want to learn why this is not working properly.

I have router that initialize view which initialize entity collection and views like so:

advertiser_manage_campaign: function () {
    this.campaignListView = new window.CampaignListView;
    this.mainSidebar = new window.MainSidebar;
},

CampaignListView:

window.CampaignListView = Backbone.View.extend({

    el: ("#right_column"),

    initialize: function () {   
        this.render();

        this.campaignCollection = new Campaign.CampaignCollection;
        this.campaignCollectionView = new Campaign.CampaignCollectionView({ model: this.campaignCollection });
        this.campaignCollection.fetch();
    },

    events: {
        "click .campaign_dialog": "openCampaignDialog"
    },

    openCampaignDialog: function (e) {        
        var that = this;
        var itemID = $(e.target).attr("item-id");
        var model = {}; //model to populate dialog inputs
        if (!isNaN(itemID))
            model = this.campaignCollection.get(itemID).toJSON(); //get existing model from collection <- after described procedure, error

        Campaign.Dialog.open(model, function (data) {
            if (isNaN(itemID)) {//model does not exist, create
            that.campaignCollection.create(data, { wait: true,
                    error: function (model, error) {
                        dialoger.showErrors(JSON.parse(error.responseText).errors);
                    },
                    success: function (mdl, response) { window.Campaign.Dialog.close(); }
                });               

            } else {//model exist, update
                model = that.campaignCollection.get(itemID);
                model.save(data, { wait: true,
                    error: function (mdl, error) {
                        dialoger.showErrors(JSON.parse(error.responseText).errors);
                    },
                    success: function (mdl, response) { window.Campaign.Dialog.close(); }
                });
            }
        });
        return false;
    },

    render: function () { 
        $(this.el).html(window.Templates.getHTML("campaign_list_view", {}));
        $(".button", $(this.el)).button();
    }
});

–

openCampaignDialog 

is for both edit models and creating new. Every view(table row) of model
has button with class “.campaign_dialog” and there is button for adding new model with same class.

Campaign.Dialog.open

shows dialog populated with model and in callback returns JSON from dialog form.

If I create new model via dialog, I can edit it right away, but when I create new model, change view, back to this view, create again new model, change view and then again back, click edit on last added item, I get error on commented line as model with this ID is not in collection, although it is. Response from server is OK. Obviously, I’m doing something wrong and after one day, I don’t see what it is.

Alternative solution I’ve came up to is to create and populate dialog from event of model view (this works), but I thought that CampaingCollectionView or CampaingView should not deal with adding or editing models so I’ve implemented this in ‘higher’ view.

Thanks everyone for helping me…

Edit:

var CampaignCollectionView = Backbone.View.extend({

    el: (".content_table tbody"),

    initialize: function () {
        this.model.bind("reset", this.render, this);
        this.model.bind("add", this.add, this);
    },

    render: function () {
        $(this.el).empty();
        _.each(this.model.models, function (campaign) {
            $(this.el).append(new CampaignView({ model: campaign }).render().el);
        }, this);
        return this;
    },

    add: function (model) {
        window.Appender.AppendAndScroll($(new CampaignView({ model: model }).render().el), this.el);
    }

});
  • 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-06-10T04:43:21+00:00Added an answer on June 10, 2026 at 4:43 am

    I’ve found solution.

    Problems arise, though, when we bind objects together through these
    events but we don’t bother unbinding them. As long as these objects
    are bound together, and there is a reference in our app code to at
    least one of them, they won’t be cleaned up or garbage collected. The
    resulting memory leaks are like the zombies of the movies – hiding in
    dark corners, waiting to jump out and eat us for lunch.

    Source: http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/

    Author suggests unbinding mechanism, but I’m going to reuse same objects if exist.

    Router:

    advertiser_manage_campaign: function () {
        if (!this.campaignListView)
            this.campaignListView = new window.CampaignListView;
        else
            this.campaignListView.initialize();
    
    
        this.mainSidebar = new window.MainSidebar;
    },
    

    If someone thinks this is not best solution, I would like to hear why.

    Thank you all who tried to help!

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

Sidebar

Related Questions

I have a simple problem but I just don't understand any of the examples
I just don't get it where is the problem but here's the error: Fatal
My problem is fairly easy but I just don't know how to solve it.
I just don't know how to explain my problem. So I have created an
This is propably a farcical problem but I just don't see the reason for
Maybe I just don't know .NET well enough yet, but I have yet to
I have read other similar posts but I just don't understand what I've done
I just have rewritten my mysql code to PDO, but I just don't get
I just don't get it. I have a function to read stemmed strings from
I just don't understand. It worked fine at one point but not it's not

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.