From 8085c5ac5a1b178ca769013ef18cb9f10879a0ab Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 6 Sep 2012 09:19:03 +0000 Subject: [PATCH] Prevent JS events from being garbage collected when a media.view.Modal is re-rendered. see #21390, #21776. git-svn-id: https://develop.svn.wordpress.org/trunk@21771 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 7 +++++++ 1 file changed, 7 insertions(+) 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;