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 6672477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:30:46+00:00 2026-05-26T03:30:46+00:00

I am currently using Backbone.js collection and View and I am attempting to bind

  • 0

I am currently using Backbone.js collection and View and I am attempting to bind a collections function to a function inside of the view. I thought that I could simply create a function inside of the collection and then bind it inside of the view. Unfortunately, it keeps referencing the collections method. Here is my code.

var RightPaneCollectionView = Backbone.View.extend({
    initialize: function(){
        _.bindAll(this, 'render', 'add', 'remove', 'remove_by_name');   // bind the methods to this scope
        this.el.html("");   // clear out the view
        this.collection.bind('removeByName', this.remove_by_name);
                    this.collection.bind('remove', this.remove);
    },
    remove_by_name: function(){ console.log("Removing by name inside view.")
    }
}

var RightPaneCollection = Backbone.Collection.extend({
   model: RightPaneButtonModel,
url: "",
removeByName: function(){
    console.log("Removing by name inside collection");
}
});

I’d like to be able to do the falling

 rightPaneCollection.removeByName("foo");

and have it reference the view. I’m not sure I’m going about this in the correct manner. Currently the remove works correctly by referencing the remove method inside of the view.

Thanks for you help!

  • 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-26T03:30:47+00:00Added an answer on May 26, 2026 at 3:30 am

    Is this what you are looking for?

    Basically, I am triggering a “removeByName” event from the collection when the item is removed and I pass the name of the item that was removed. In the View, I am binding to that event name and calling the view’s function and accessing the name of the item being removed.

    var RightPaneCollectionView = Backbone.View.extend({
        initialize: function(){
            _.bindAll(this, 'remove_by_name');
            this.el.html("");   // clear out the view
            this.collection.bind('removeByName', this.remove_by_name);
        },
        remove_by_name: function(name){ 
            console.log("Removing by name inside view: " + name)
        }
    }
    
    var RightPaneCollection = Backbone.Collection.extend({
       model: RightPaneButtonModel,
       url: "",
       removeByName: function(name){
           var itemToRemove = this.find(function(item){return item.get("name") === name;});
           if(itemToRemove) {
               this.remove(itemToRemove);
               this.trigger("removeByName", name);
           }
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that is currently using backbone.js 0.5.3 with backbone local
I've just started using Backbone.js. I want to create a Collection and add some
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
I'm currently using PHP, JAVASCRIPT, MYSQL, XHTML, CSS to develop my site. Note that
I am using backbone to build my web app. Currently I am facing an
I'm using default drag and drop inside a backbone application i'm listening event in
I'm using backbone.js, and I've got a collection with does fetch() sometimes. I don't
I want to create a tree table to display files using backbone.js + jQuery.
I am in the process of learning Backbone.js. I currently assume that if one
I'm having some difficulty with backbone js. Currently, I have a rails app that

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.