Giter VIP home page Giter VIP logo

Comments (4)

xtellurian avatar xtellurian commented on May 10, 2024 1

One workaround:

Add an extra class to your input like this:

<input id="autoComplete" class="autoCompleteWorkaround" >

Then you can use the class in the selector, eg:

resultsList: {                       
            ...
            destination: document.querySelector(".autoCompleteWorkaround"),
          ...
        },

from autocomplete.js.

TarekRaafat avatar TarekRaafat commented on May 10, 2024

Hello @xtellurian,

Thanks for sharing your case and your workaround for it.

The id is mainly being used by autoComplete.js for a specific purpose which is to point at "select" the input field that has to be unique in case of multiple fields are being used at the same page.
This is considered as a good practice for selecting a unique HTML element that's not repeated, while still class selection is supported by autoComplete.js as well but not recommended.

Adding the input field style to the library's main stylesheet through the id was done just to get developers started as quickly as possible, and it could be overwritten easily by adding a class or a new id to the input field with the required styling from a separate CSS sheet, as shown in the below example.

N.B.: resultsList render destination is being handled automatically by autoComplete.js pointing at the specified selector no need to be handled manually.

  • First Instance
<input id="autoComplete-01" class="autoComplete-01" type="text">
 // The autoComplete.js Engine instance One
const autoComplete_01 = new autoComplete({
  selector: "#autoComplete-01",

});
  • Second Instance
<input id="autoComplete-02" class="autoComplete-02" type="text">
 // The autoComplete.js Engine instance Two
const autoComplete_02 = new autoComplete({
  selector: "#autoComplete-02",

});

Cheers and have a nice day! :)

from autocomplete.js.

xtellurian avatar xtellurian commented on May 10, 2024

Hey @TarekRaafat thanks for the reply :)

Considering the situation with multiple autoComplete engines, like so:

<input id="autoComplete-02" class="autoComplete-02" type="text">
// The autoComplete.js Engine instance One
const autoComplete_01 = new autoComplete({
  selector: "#autoComplete-01",
});

Won't the CSS fail to target correctly the element, because the CSS is targetting an element with id="autoComplete" ?

from autocomplete.js.

TarekRaafat avatar TarekRaafat commented on May 10, 2024

v8.0

from autocomplete.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.