GithubHelp home page GithubHelp logo

Comments (8)

yahyaerturan avatar yahyaerturan commented on June 20, 2024 1

👍 Looks great. Thank you.. Next release will be a loaded gun :)

from virtual-select.

sa-si-dev avatar sa-si-dev commented on June 20, 2024

It is an interesting feature to have.

I will work on it in the future release.

Thanks for your suggesion.

from virtual-select.

frg avatar frg commented on June 20, 2024

@yahyaerturan This functionality has been added in #7 however since this plugin does not deal with importing the options from the DOM directly you'll have to query and parse the terms manually.

const select = document.querySelector("#select");
const options = Array.prototype.slice.call(select.options)
    .map(x => {
        return {
            label: x.text,
            value: x.value,
            terms: x.getAttribute("data-aliases").split(","),
        }
    });

from virtual-select.

yahyaerturan avatar yahyaerturan commented on June 20, 2024

If I get it right, this will result in a second mapping of json data as we set options by json when initializing? The html I wrote here as a sample of final output. Will this be done after initializing virtual select? More generic solution might be defining searchable json keys when initialising and leave the rest to the backend.

from virtual-select.

frg avatar frg commented on June 20, 2024

The html I wrote here as a sample of final output.

This plugin does not generate a select HTML element which means it also does not generate option HTML elements.

You would initialize the plugin as shown below

VirtualSelect.init({
  ele: '#sample-select',
  options: [
    { label: 'Options 1', value: '1', terms: ['london', 'england'] },
    { label: 'Options 2', value: '2' },
    { label: 'Options 3', value: '3' },
  ],
});

from virtual-select.

sa-si-dev avatar sa-si-dev commented on June 20, 2024

@yahyaerturan This functionality has been added in #7 however since this plugin does not deal with importing the options from the DOM directly you'll have to query and parse the terms manually.

const select = document.querySelector("#select");
const options = Array.prototype.slice.call(select.options)
    .map(x => {
        return {
            label: x.text,
            value: x.value,
            terms: x.getAttribute("data-aliases").split(","),
        }
    });

@frg, it is not recommanded to read data from DOM element. The main problem, this plugin trying to solve is, reduce the no.of DOM element.

It is good to handle data in JS object for better performance.

from virtual-select.

frg avatar frg commented on June 20, 2024

I agree, if I understood @yahyaerturan correctly by his example he already has a select element on his page which he's like to convert to using the plugin. I could have misunderstood.

from virtual-select.

sa-si-dev avatar sa-si-dev commented on June 20, 2024

Great plugin, thank you.

It would be really nice to add aliases to labels for searching. I am using this library instead of bootstrap-select with BS5.

    <option value="27" data-aliases="turkey,middle east">Istanbul</option>
    <option value="43" data-aliases="england,united kingdom,europe">London</option>

This is the final html I proposed. We should be able to find "London" option when we type england or europe for example.

@yahyaerturan as you requested, we have implemented the feature to allow using alias for searching.

This feature is available in the release v.1.0.3 (more details)

from virtual-select.

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.