Skip to content
Snippets Groups Projects

Issue #3345731 #comment-15173067 Fixed an error: Error: cannot call methods on...

Merged Issue #3345731 #comment-15173067 Fixed an error: Error: cannot call methods on...
All threads resolved!
All threads resolved!
Files
2
@@ -3,7 +3,7 @@
* Autocomplete based on jQuery UI.
*/
(function ($, Drupal) {
(function ($, Drupal, once) {
'use strict';
@@ -225,7 +225,9 @@
Drupal.behaviors.autocomplete = {
attach: function (context) {
// Act on textfields with the "form-autocomplete" class.
var $autocomplete = $(context).find('input.form-autocomplete').once('autocomplete');
var $autocomplete = $(
once('vaf-autocomplete', 'input.form-autocomplete', context)
);
if ($autocomplete.length) {
// Allow options to be overriden per instance.
var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist');
@@ -241,11 +243,13 @@
},
detach: function (context, settings, trigger) {
if (trigger === 'unload') {
$(context).find('input.form-autocomplete')
.removeOnce('autocomplete')
.autocomplete('destroy');
var autocompleteForm = $(context).find('input.form-autocomplete');
if (autocompleteForm.hasClass('ui-autocomplete')) {
autocompleteForm.autocomplete('destroy');
}
once.remove('vaf-autocomplete', 'input.form-autocomplete', context);
}
}
},
};
/**
@@ -299,5 +303,4 @@
.not(this.input)
.serializeArray();
};
})(jQuery, Drupal);
})(jQuery, Drupal, once);
Loading