🇮🇳India @Akash_Daimari

Account created on 26 September 2016, over 8 years ago
#

Recent comments

🇮🇳India Akash_Daimari

In order to remove the Taxonomy Term Id in autocomplete using jQuery for the time being.

(function($, Drupal, drupalSettings){
  'use strict';

  Drupal.behaviors.common = {
    attach: function(context) {
      // Remove TID's onload.
      Drupal.common.remove_tid();

      // Remove TID's onchange.
      jQuery('body').find('.form-autocomplete').on('autocompleteclose', function() {
        Drupal.common.remove_tid();
      });
    }
  };

  Drupal.common = {
    remove_tid: function () {
      var field_autocomplete = jQuery('body').find('.form-autocomplete');
      field_autocomplete.each(function (event, node) {
        var val = $(this).val();
        var match = val.match(/\s\(.*?\)/g);
        if (match) {
          $(this).data('real-value', val);
          $(this).val(val.replace(/\s\(.*?\)/g, '' ));
        }
      });
    }
  };
})(jQuery, Drupal, drupalSettings);

Code Credit Goes to the commenters in (https://drupal.stackexchange.com) issue:
Hide the term id on autocomplete widget

Production build 0.71.5 2024