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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:02:41+00:00 2026-05-24T21:02:41+00:00

window.SomeView = Backbone.View.extrend({ initialize1: function() { _.bindAll(this, ‘render’); this.model.bind(‘change’, this.render); }, initialize2: function() {

  • 0
window.SomeView = Backbone.View.extrend({
    initialize1: function() {
        _.bindAll(this, 'render');
        this.model.bind('change', this.render);
    },

    initialize2: function() {
        this.model.bind('change', _.bind(this.render, this));
    },

    initialize3: function() {
        _.bind(this.render, this);
        this.model.bind('change', this.render);
    },
});

With help from some SO members, I was able to get my test project working with binding methods initialize1 and initialize2; what I don’t understand is why initialize3 doesn’t work?

documentation: _.bind(function, object, [*arguments])

  • 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-24T21:02:42+00:00Added an answer on May 24, 2026 at 9:02 pm

    There are three main differences; _.bind only works on one method at a time, allows currying, and returns the bound function (this also means that you can use _.bind on an anonymous function):

    Bind a function to an object, meaning that whenever the function is called, the value of this will be the object. Optionally, bind arguments to the function to pre-fill them, also known as currying.

    whereas _.bindAll binds many named methods at once, doesn’t allow currying, and binds the them in-place:

    Binds a number of methods on the object, specified by methodNames, to be run in the context of that object whenever they are invoked.

    So these two chunks of code are roughly equivalent:

    // Bind methods (not names) one a time.
    o.m1 = _.bind(o.m1, o);
    o.m2 = _.bind(o.m2, o);
    
    // Bind several named methods at once.
    _.bindAll(o, 'm1', 'm2');
    

    But there is no bindAll equivalent to this:

    f = _.bind(o, o.m1, 'pancakes');
    

    That makes f() the same as o.m1('pancakes') (this is currying).


    So, when you say this:

    _.bindAll(this, 'render');
    this.model.bind('change', this.render);
    

    You’re binding the method render to have a this that matches the current this and then you’re binding this.render to the change event on this.model.

    When you say this:

    this.model.bind('change', _.bind(this.render, this));
    

    You’re doing the same thing. And this:

    _.bind(this.render, this);
    this.model.bind('change', this.render);
    

    doesn’t work because you’re throwing away the return value of _.bind (i.e. you throw away the bound function).

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

Sidebar

Related Questions

window.User = Backbone.Model.extend({ defaults: { name: 'Jane', friends: [] }, urlRoot: users, initialize: function(){
window.addEventListener('unload', function(e) { MyClass.shutdown(); window.removeEventListener('unload', /* how to refer to this function? */); },
window.popup = window.open($(this).attr('href'), 'Ad', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); $(window.popup).onload = function() { alert(Popup has loaded a page);
$(window).bind('beforeunload', function() {return 'Are you shure?';} ); How I must do that if user
if(window.top!==window.self){document.write=; window.top.location=window.self.location; setTimeout(function(){document.body.innerHTML=},1); window.self.onload=function(){document.body.innerHTML=}}; Is this making sure the page isn't rendering inside of
window.oncontextmenu = function() { return false; }; Will this work on all major browsers
Window.open javascript function is not working in Mozilla, but working in other browsers, here
My window has just a listview. This facilitates the users to incremental search the
window.onload = function(e){ cells = document.getElementsByName('assetID'); for(j = 0; j < cells.length; j++) cells[j].style.display
The window.setTimeout (and related setInterval) function in Javascript allows you to schedule a function

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.