From fd1652d6bb386050e0f7fef2219a959d716e39d8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 29 Jul 2014 14:57:21 +0000 Subject: [PATCH] Media Grid: Close the modal if the attachment is deleted. props ericlewis. fixes #28819. git-svn-id: https://develop.svn.wordpress.org/trunk@29322 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-grid.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js index fcd66070a9..4c7b55b411 100644 --- a/src/wp-includes/js/media-grid.js +++ b/src/wp-includes/js/media-grid.js @@ -362,6 +362,7 @@ initialize: function() { var self = this; + media.view.Frame.prototype.initialize.apply( this, arguments ); _.defaults( this.options, { @@ -371,12 +372,16 @@ this.gridRouter = this.options.gridRouter; this.library = this.options.library; + if ( this.options.model ) { this.model = this.options.model; } else { this.model = this.library.at( 0 ); } + // Close the modal if the attachment is deleted. + this.listenTo( this.model, 'destroy', this.close, this ); + this.createStates(); this.on( 'content:create:edit-metadata', this.editMetadataMode, this ); @@ -385,7 +390,7 @@ // Bind default title creation. this.on( 'title:create:default', this.createTitle, this ); - this.title.mode('default'); + this.title.mode( 'default' ); this.options.hasPrevious = this.hasPrevious(); this.options.hasNext = this.hasNext();