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've just started using Backbone.js. I want to create a Collection and add some
I am using backbone to build my web app. Currently I am facing an
I want to create a tree table to display files using backbone.js + jQuery.
I'm currently using Handlebars.js (associated with Backbone and jQuery) to make a web app
Currently using cocos2d. I have a plist data name myplist.plist. Inside the plist are
Im currently using base64_encode for some $_GET params that i don't want regular user
I'm currently trying Backbone.js along with a rails app. My problem is, that I
Currently using the JQuery UI autocomplete list function JQuery UI - Autocomplete . I
Im currently using a method that looks like the following code to add script
Currently I am using backbone-rails in my Rails app. I would like to know

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.