Media Grid: on page load with `?item=` in the URL, if the model is not in the library: fetch it. Defer the triggering of `edit:attachment` until the model has been fetched.
Fixes #29052. Built from https://develop.svn.wordpress.org/trunk@29525 git-svn-id: http://core.svn.wordpress.org/trunk@29301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
68a3e1af2c
commit
5aee14e9a1
|
@ -306,10 +306,20 @@
|
|||
|
||||
// Show the modal with a specific item
|
||||
showItem: function( query ) {
|
||||
var library = media.frame.state().get('library');
|
||||
var library = media.frame.state().get('library'), item;
|
||||
|
||||
// Trigger the media frame to open the correct item
|
||||
media.frame.trigger( 'edit:attachment', library.findWhere( { id: parseInt( query, 10 ) } ) );
|
||||
item = library.findWhere( { id: parseInt( query, 10 ) } );
|
||||
if ( item ) {
|
||||
media.frame.trigger( 'edit:attachment', item );
|
||||
} else {
|
||||
item = media.attachment( query );
|
||||
media.frame.listenTo( item, 'change', function( model ) {
|
||||
media.frame.stopListening( item );
|
||||
media.frame.trigger( 'edit:attachment', model );
|
||||
} );
|
||||
item.fetch();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -373,9 +383,6 @@
|
|||
|
||||
if ( this.options.model ) {
|
||||
this.model = this.options.model;
|
||||
} else {
|
||||
// this is a hack
|
||||
this.model = this.library.at( 0 );
|
||||
}
|
||||
|
||||
this.bindHandlers();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue