Skip to content

Multiple views rendered for the same model #77

Description

@edwh

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 );
            } );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions