TarekRaafat / autoComplete.js

Simple autocomplete pure vanilla Javascript library.
https://tarekraafat.github.io/autoComplete.js
Apache License 2.0
3.95k stars 239 forks source link

Is there a way to turn autocomplete back on without creating a new wrapper element around the input? #245

Closed deniseismo closed 3 years ago

deniseismo commented 3 years ago

I can't seem to find an easy way to simply turn the autocomplete functionality back on after the autocomplete object has been uninitialized (unInit()). The init() core function seems like a solution, but it's also responsible for creating wrapper element and moving the selected input inside it, as it's stated in the docs. After a few clicks back & forth (uninit() & then init() again, for instance) we are looking at something like this:

<div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="40">
    <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="55">
        <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="75">
            <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="99">
                <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="113">
                    <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="126">
                        <div class="autoComplete_wrapper" role="combobox" aria-owns="autoComplete_list_1" aria-haspopup="true" aria-expanded="false" wfd-id="139">

I know there's always a way to solve this by changing my design, or am I missing something here as well?

folknor commented 3 years ago

You can set wrapper: false in the root of your autoComplete.js config to prevent creation of the wrapper element. That said, this should probably be fixed properly.

deniseismo commented 3 years ago

@folknor thank you, somehow missed this one.