Restore auto-complete in comment boxes beyond the first
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 8 Aug 2020 16:58:56 +0000 (12:58 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 8 Aug 2020 16:58:56 +0000 (12:58 -0400)
view/js/autocomplete.js

index c399360..0405715 100644 (file)
@@ -202,16 +202,17 @@ function string2bb(element) {
        // jQuery wrapper for yuku/old-textcomplete
        // uses a local object directory to avoid recreating Textcomplete objects
        $.fn.textcomplete = function (strategies, options) {
-               if (!(this.data('textcompleteId') in textcompleteObjects)) {
-                       let editor = new Textcomplete.editors.Textarea(this.get(0));
+               return this.each(function () {
+                       let $this = $(this);
+                       if (!($this.data('textcompleteId') in textcompleteObjects)) {
+                               let editor = new Textcomplete.editors.Textarea($this.get(0));
 
-                       this.data('textcompleteId', textcompleteObjects.length);
-                       textcompleteObjects.push(new Textcomplete(editor, options));
-               }
-
-               textcompleteObjects[this.data('textcompleteId')].register(strategies);
+                               $this.data('textcompleteId', textcompleteObjects.length);
+                               textcompleteObjects.push(new Textcomplete(editor, options));
+                       }
 
-               return this;
+                       textcompleteObjects[$this.data('textcompleteId')].register(strategies);
+               });
        };
 
        /**