Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a class as a selector, rather than id #440

Open
2 of 7 tasks
finanalyst opened this issue Feb 10, 2025 · 0 comments
Open
2 of 7 tasks

Using a class as a selector, rather than id #440

finanalyst opened this issue Feb 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@finanalyst
Copy link

  • System Information

    • Browser type and version: Firefox 135.0 (64-bit)
    • [x OS type and version: Ubuntu 22.04.5 LTS
    • WINDOWS: be sure to indicate which terminal you're using -- (i.e., cmd.exe, powershell, git- bash, cygwin, Ubuntu via windows subsystem for linux, etc...)
    • Node version (IF applicable)
      • Any error messages that may be in the console where you ran npm start
    • Any error messages in the JS console
  • Describe the bug

In the documentation it says:

selector (optional) Responsible for the input, textarea, or contentEditable element selection
Type: String of selector | Function returns Element
Default: #autoComplete

In order to make the website responsive, I have two <input class="myAutocomplete" ...>, one in a div that is visible for desktops, and one for touch devices.

I have the following in the JS

autoCompleteJS = new autoComplete({
    selector: ".myAutoComplete",
    placeHolder: "🔍",
...

When the first input tag, in the html document (in my case for the touch format), is visible, the autoComplete functionality works as expected.
When the second input tag in the html document (in my case for the desktop format) is visible, the autoComplete functionality does not work.

The aim is to have both input tags operate on the same data.

So, either the documentation is slightly inaccurate, as not every selector is possible, or incomplete in that only the first instance of the selector will be chosen (in the same way the querySelector('.myAutoComplete') will return the first instance).

If this is not a bug, but expected behaviour, what is the best way to have two inputs? Or are two instances of autoComplete needed?

@finanalyst finanalyst added the bug Something isn't working label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant