Coder Social home page Coder Social logo

bmsvieira / bvselect-vanillajs Goto Github PK

View Code? Open in Web Editor NEW
113.0 2.0 16.0 833 KB

BVSelect - Vanilla Javascript Fully Customizable SelectBox

License: MIT License

CSS 8.90% HTML 21.11% JavaScript 69.99%
javascript opensource selectbox purejavascript nojquery customizable vanilla-javascript vanillajs javascript-es6

bvselect-vanillajs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bvselect-vanillajs's Issues

no keyboard navigation

Was looking into this to see if I should recommend it to a friend. Being a11y friendly is always a big deal. I noticed that I cannot use this with keyboard navigation. I cannot open a selectbox with a keyboard trigger and I cannot tab to select boxes.

I get this is your open source project and not making any demands, just saying that accessibility is an important aspect of choosing a select control with actual legal implications in the US (for the site that uses it). You might consider either prioritizing these features or clearly stating the limitation at the top of the readme

Dynamicly creation option elements breaks when value contain spaces

When option elements are created dynamicly, the values need to be encapsulated.
Right now, this is not the case, resulting in broken html when values contain spaces.

To fix this, change:

                document.getElementById(this.selector).insertAdjacentHTML('beforeend',
                    "<option "+change_img+" "+change_icon+" "+change_separator+" "+change_disabled+" value="+properties.options[i].value+" >"+properties.options[i].inner_text+"</option>");

To:

                document.getElementById(this.selector).insertAdjacentHTML('beforeend',
                    "<option "+change_img+" "+change_icon+" "+change_separator+" "+change_disabled+" value=\""+properties.options[i].value+"\" >"+properties.options[i].inner_text+"</option>");

Uncaught ReferenceError: BVSelect is not defined

I have loaded the BVSelect JS and CSS files into my Javascript ES6 file and created a #selectbox element.

When I try to use new BVSelect() it fails with:

Uncaught ReferenceError: BVSelect is not defined

The browser shows that the .js and .css files are loaded succesfully and my code intellisense does pick up the BVSelect class.

Here's my javascript:

    $(`
    <select id="selectbox">
      <option data-separator="true"> Select Option </option>
      <option value="1"> Option 1 </option>
      <option value="2"> Option 2 </option>
      <option value="3" disabled> Option 3 </option>
      <option value="4"> Option 4 </option>
    </select>`).appendTo(this.$contentDiv);

    var demo = new BVSelect('#selectbox'); 

It is without accessibility.

Some things that are important to add:
1 - Aria attributes
2 - Keyboard navigation
3 - Mobile close button (X)

I really like these libraries to create customized fields, but we have to take great care not to forget accessibility.

Selector by class

Is there a way to a make it work with a class as a selector instead of ID? Awesome script

Show images for selected item

An image can be added to each menu entry, but this does not get displayed for the selected item in the top selection.

Can this be added as the selected item displayed at the top should reflect the line item content for better presentation.

Please see the example below.

Thanks

image

Suggestion - Setting for custom output elements

First of all, thank you for this awesome class.

I have a request / suggestion for a future enhancement:
It would be nice to be able to overrule the html output via the settings.

For example:
I stumbled upon a performance issue when dealing with a list of 1500 items including image previews.
Allthough the image are only a few kb, i t's quite a performance hit.
Therefor I needed to lazy-load them.
To be able to do that I had to modify the source code.

 // Check for Attachment
 if (optionImg) {
    var has_attachment = "<img data-src=" + optionImg + " class='lazyload'>";
} 

No big deal ofcourse, but it would be super nice if such alteration could be added to the settings object.

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.