Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple views rendered for the same model #77

Open
edwh opened this issue Dec 20, 2016 · 1 comment
Open

Multiple views rendered for the same model #77

edwh opened this issue Dec 20, 2016 · 1 comment

Comments

@edwh
Copy link

edwh commented Dec 20, 2016

I haven't managed to get a clear reproduction of this case yet, but I have a collection view where one of the models in the collection results in multiple views.

Has anyone else seen this? I've got a speculative fix, to check if the model already exists.

       _registerCollectionEvents : function() {
            this.listenTo( this.collection, "add", function( model ) {
                var modelView;

                if( this._hasBeenRendered ) {
                    **modelView = this.viewManager.findByModelCid( model.cid );

                    if (!modelView) {**
                        modelView = this._createNewModelView( model, this._getModelViewOptions( model ) );
                        this._insertAndRenderModelView( modelView, this._getContainerEl(), this.collection.indexOf( model ) );
                    **}**
                }

                if( this._isBackboneCourierAvailable() )
                    this.spawn( "add", modelView );
                else this.trigger( "add", modelView );
            } );

@edwh
Copy link
Author

edwh commented Dec 22, 2016

Well, that fix didn't work. Anyone else seen this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant