ajax - Quick Edit: Selected Custom Taxonomy Not Refreshing After Save

admin2025-01-08  3

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.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Dec 11, 2014 at 17:07 John PedenJohn Peden 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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" );
           }
        });
     }
  };
});
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736267274a1184.html

最新回复(0)