Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions js/attached-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ window.CMBAP = window.CMBAP || {};
app.$.retrievedPosts = $wrap.find( '.retrieved' );
app.$.attachedPosts = $wrap.find( '.attached' );
app.doType = $wrap.find( '.object-label' ).length;
// Check for multiple attached-post meta boxes
app.$.attachedBoxes = $wrap.length;
};

app.init = function() {
Expand Down Expand Up @@ -376,6 +378,7 @@ window.CMBAP = window.CMBAP || {};
};

app._openSearch = function( evt ) {
app.updateRetrievedPosts( $(this) );
app.openSearch( $( evt.currentTarget ) );
};

Expand All @@ -388,6 +391,14 @@ window.CMBAP = window.CMBAP || {};
app.search.trigger( 'open' );
};

app.updateRetrievedPosts = function( $this ){
// If more than one custom_attached_posts update cache with current metabox context
if ( app.$.attachedBoxes > 1 ) {
var $wrap = $this.closest(' .attached-posts-wrap' );
app.$.retrievedPosts = $wrap.find( '.retrieved' );
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;?


$( app.init );

} )( window, document, jQuery, window.CMBAP );