Wednesday 13 July 2016

How to add select event to auto complete functionality in Drupal?

(function ($) {
  Drupal.behaviors.autocompleteSupervisor = {
    attach: function (context) {
      $("input#edit-autocompleteField", context).bind('autocompleteSelect', function(event, node) {
        console.log($(this).val()); // user-entered string
        console.log($(node).data('autocompleteValue')); // key of selected item
        console.log($(node).text()); // label of selected item
      });
    }
  };
})(jQuery);

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.