Skip to content


Subversion checkout URL

You can clone with
Download ZIP


CollectionBinder.managerForModel does not use internal keys? #131

katowulf opened this Issue · 4 comments

2 participants


Hello again, apparently it's CollectionBinder today over here at my dev box : ) (actually, it's bug fix day, so there's lots of libs getting explored that I don't normally delve too deeply into)

I'm trying to utilize CollectionBinder to retrieve a view it has created, so that I can interact with it. In doing so, I ran across this interesting tidbit:

      getManagerForModel: function(model){
         var i, elManager, elManagers = _.values(this._elManagers);

         for(i = 0; i < elManagers.length; i++){
            elManager = elManagers[i];

            if(elManager.getModel() === model){
               return elManager;

         return undefined;

      _onCollectionAdd: function(model){
         this._elManagers[model.cid] = this._elManagerFactory.makeElManager(model);


Note that we have all the elManagers stored by model.cid, but then getManagerForModel does not utilize it to retrieve them, instead iterating the entire list.

Is this intentional? Have I missed something obvious?



oops :)

Yeah, it appears like the getManagerForModel could be rewrittwen to be more efficient. Good catch.
I don't have a computer for another 10 days :( I am in between jobs. You are welcome to make the change / do a pull request.


Okay, once you've looked at the attr/prop changes, and approved/denied that, I'll put in a fix for this. Otherwise, we'll end up with a host of commits under that one and it should really stand on its own because of the number of files touched.


I just merged your previous pull request - thank you for that change.


I tested this fix in Safari, Firefox, IE 9, and Chrome (latest builds all), against all the CollectionBinder example pages and also ran the specs in all browsers.

@theironcook theironcook closed this issue from a commit
@katowulf katowulf Fixes theironcook/Backbone.ModelBinder#131
Optimize CollectionBinder::getManagerForModel to use keyed values already stored internally.

defaultBindings was generating a js error; this did not cause any test cases to fail because it occurred after test cases completed. However, since the checkboxes return boolean values, there is no .replace value available; corrected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.