Media: Add render tracking to views. see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-19 22:48:11 +00:00
parent c185f0c9bd
commit 663cde2c51

View File

@ -682,8 +682,10 @@
subviews.selector = selector; subviews.selector = selector;
}, this ); }, this );
if ( ! options.silent ) if ( ! options.silent ) {
_.each( views, this._maybeRender, this );
this[ method ]( $selector, els, options ); this[ method ]( $selector, els, options );
}
return this; return this;
}, },
@ -755,6 +757,8 @@
render: function() { render: function() {
var root = this._views['']; var root = this._views[''];
_.each( this.all(), this._maybeRender, this );
if ( root ) if ( root )
this.replace( this.view.$el, _.pluck( root, 'el' ) ); this.replace( this.view.$el, _.pluck( root, 'el' ) );
@ -763,6 +767,7 @@
this.replace( this.view.$( selector ), _.pluck( views, 'el' ) ); this.replace( this.view.$( selector ), _.pluck( views, 'el' ) );
}, this ); }, this );
this.rendered = true;
return this; return this;
}, },
@ -813,6 +818,16 @@
$target.append( els ); $target.append( els );
return this; return this;
},
// #### Internal. Maybe render a view.
_maybeRender: function( view ) {
if ( ! view.views || view.views.rendered )
return;
view.render();
view.views.rendered = true;
} }
}); });
@ -1148,14 +1163,14 @@
upload: state.get('upload'), upload: state.get('upload'),
AttachmentView: state.get('AttachmentView') AttachmentView: state.get('AttachmentView')
}).render() ); }) );
}, },
uploadContent: function() { uploadContent: function() {
// In the meantime, render an inline uploader. // In the meantime, render an inline uploader.
this.content.view( new media.view.UploaderInline({ this.content.view( new media.view.UploaderInline({
controller: this controller: this
}).render() ); }) );
}, },
// Sidebars // Sidebars