diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 30136b3b1f..c8abb798bc 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -101,6 +101,13 @@ }, render: function() { + // Ensure content div exists. + this.options.$content = this.options.$content || $('
'); + + // Detach the content element from the DOM to prevent + // `this.$el.html()` from garbage collecting its events. + this.options.$content.detach(); + this.$el.html( this.template( this.options ) ); this.$('.media-modal-content').append( this.options.$content ); return this;