From b186d63721a8273bc70185d4c0c13d5c8b869ae1 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 6 Dec 2012 06:56:06 +0000 Subject: [PATCH] Media: When the attachment details view changes to another view or attachment, save compat fields on destroy. (We already do this for non-compat fields.) props koopersmith. fixes #22776. git-svn-id: https://develop.svn.wordpress.org/trunk@23098 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index aef05dd11b..7054e09cc6 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -4080,6 +4080,13 @@ this.model.on( 'change:compat', this.render, this ); }, + dispose: function() { + if ( this.$(':focus').length ) + this.save(); + + return media.View.prototype.dispose.apply( this, arguments ); + }, + render: function() { var compat = this.model.get('compat'); if ( ! compat || ! compat.item ) @@ -4100,7 +4107,8 @@ save: function( event ) { var data = {}; - event.preventDefault(); + if ( event ) + event.preventDefault(); _.each( this.$el.serializeArray(), function( pair ) { data[ pair.name ] = pair.value;