mirror of
git://develop.git.wordpress.org/
synced 2025-02-26 01:22:47 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@29525 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
27cd1b4f92
commit
48d83dcc66
@ -306,10 +306,20 @@
|
|||||||
|
|
||||||
// Show the modal with a specific item
|
// Show the modal with a specific item
|
||||||
showItem: function( query ) {
|
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
|
// 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 ) {
|
if ( this.options.model ) {
|
||||||
this.model = this.options.model;
|
this.model = this.options.model;
|
||||||
} else {
|
|
||||||
// this is a hack
|
|
||||||
this.model = this.library.at( 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bindHandlers();
|
this.bindHandlers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user