This seems to be a common problem as it was asked here but I can't seem to fix it on my own installation. I've setup a filter to modify the quick edit button to identify the correct selected value for a custom taxonomy dropdown in the quick editor. This works on page refresh but not after changing it and clicking update. Apparently it's a JS error but I can't figure out how to fix it. As I understand, the function needs to apply to the quick edit row AFTER it's been modified by the initial AJAX call.
Here is my code:
The code I originally posted here was for bulk edit. Please see the answer below for the solution.
This seems to be a common problem as it was asked here but I can't seem to fix it on my own installation. I've setup a filter to modify the quick edit button to identify the correct selected value for a custom taxonomy dropdown in the quick editor. This works on page refresh but not after changing it and clicking update. Apparently it's a JS error but I can't figure out how to fix it. As I understand, the function needs to apply to the quick edit row AFTER it's been modified by the initial AJAX call.
Here is my code:
The code I originally posted here was for bulk edit. Please see the answer below for the solution.
Added this code to updated the selected field by identifying the appropriate value in the taxonomy column:
jQuery(document).ready(function($) {
// Create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// Overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// Call the original WP edit function
$wp_inline_edit.apply( this, arguments );
// get the post ID
var $post_id = 0;
if ( typeof( id ) == 'object' )
$post_id = parseInt( this.getId( id ) );
if ( $post_id > 0 ) {
// get the $outcome value from the relevant column
var $outcome = $( '#outcome-' + $post_id ).text();
// mark the current $outcome value as selected
$("#tip_outcome_selection option").each(function(){
if($( this ).val() == $outcome){
$( this ).attr( "selected", "selected" );
}
});
}
};
});