• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple dual listbox build in plain Javascript and some simple styling. (no other libraries of frameworks required)

Build Status Coverage Status Code Climate Lintly npm Known Vulnerabilities BCH compliance

NPM

Changes

Solves the duplicate option rendering problem, as mentioned in this issue #63

Dual Listbox

Make your multi select pretty and easy to use with only javascript. No other frameworks/libraries required.

Try the demo

Styling. (From the stylesheet that can be found in the dist folder)

Default

with selected options and one option highlighted.

selected

Install

Install with npm

$ npm i dual-listbox --save

CDN

<script src="https://cdn.jsdelivr.net/npm/dual-listbox/dist/dual-listbox.min.js"></script>
<link
    href="https://cdn.jsdelivr.net/npm/dual-listbox/dist/dual-listbox.css"
    rel="stylesheet"
/>

<!-- for pinned version -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dual-listbox.min.js"></script>
<link
    href="https://cdn.jsdelivr.net/npm/[email protected]/dist/dual-listbox.css"
    rel="stylesheet"
/>

Usage

let dualListbox = new DualListbox("select"); // Selects the first selectbox on the page.
let dualListbox = new DualListbox(".select"); // Selects the first element with the class 'select'
let dualListbox = new DualListbox("#select"); // Selects the first element with the id 'select'

let select = document.querySelector("#select");
let dualListbox = new DualListbox(select); // Add a HTMLElement

You can also pass some options to the DualListbox

let dualListbox = new DualListbox("#select", {
    addEvent: function (value) {
        // Should use the event listeners
        console.log(value);
    },
    removeEvent: function (value) {
        // Should use the event listeners
        console.log(value);
    },
    availableTitle: "Different title",
    selectedTitle: "Different title",
    addButtonText: ">",
    removeButtonText: "<",
    addAllButtonText: ">>",
    removeAllButtonText: "<<",

    sortable: true,
    upButtonText: "ᐱ",
    downButtonText: "ᐯ",

    draggable: true,

    options: [
        { text: "Option 1", value: "OPTION1" },
        { text: "Option 2", value: "OPTION2" },
        { text: "Selected option", value: "OPTION3", selected: true },
    ],
});

dualListbox.addEventListener("added", function (event) {
    console.log(event);
    console.log(event.addedElement);
});
dualListbox.addEventListener("removed", function (event) {
    console.log(event);
    console.log(event.removedElement);
});

Try it online on JSFiddle.

Exposed elements

All the elements should be exposed. This way it should be possible to add custom attributes to the element of choice.

let dualListbox = new DualListbox("#select");

// Access the buttons:
dualListbox.add_button.setAttribute("a", "a");
dualListbox.add_all_button.setAttribute("a", "a");
dualListbox.remove_button.setAttribute("a", "a");
dualListbox.remove_all_button.setAttribute("a", "a");

// Access the search field:
dualListbox.search_left.classList.add("some_class");
dualListbox.search_right.classList.add("some_class");

// Access the list containers:
dualListbox.selectedList.setAttribute("a", "a");
dualListbox.availableList.setAttribute("a", "a");

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Maykin Media

License

Copyright © 2019 Maykin Media Licensed under the MIT license.

More Repositories

1

django-admin-index

Change the Django admin index page without too much hassle or visual changes.
Python
89
star
2

django-timeline-logger

A reusable Django app to log actions and display them in a timeline 📝
Python
53
star
3

drf-jsonschema-serializer

JSON schema integration for Django REST Framework
Python
38
star
4

django-exportdb

Python
15
star
5

django-regex-redirects

Django redirects, with regular expressions
Python
14
star
6

django-camunda

Interact with the Camunda API from Django/Celery
Python
13
star
7

bem.js

DOM selection and manipulation using BEM (Block, Element, Modifier).
JavaScript
9
star
8

mobetta

Python
7
star
9

objects-api

API and admin interface to manage Objects of certain Objecttypes. An object can be anything whether its a monument, report, tree or a permit.
Python
7
star
10

consumerjs

Consumerjs simplifies REST with an ORM like approach. Built on top of Axios.
JavaScript
7
star
11

django-activiti

A Python/Django library to connect to Activiti (https://www.activiti.org/)
Python
6
star
12

python-ideal

Implementation of the iDEAL v3.3.1 specification in Python.
Python
6
star
13

django-log-outgoing-requests

Log outgoing requests made by requests library
Python
5
star
14

django-loose-fk

Django and DRF integration to handle loose foreign keys
Python
5
star
15

mail-editor

Python
5
star
16

djadyen

A django adyen component/dropin integration
Python
5
star
17

mozilla-django-oidc-db

Database-backed settings for mozilla-django-oidc, with modified unique identifiers for users
Python
4
star
18

default-app

Boilerplate template for a third party django app
Python
4
star
19

microscope-sass

Sass microframework for building scoped user interfaces.
HTML
4
star
20

django-dbcache-fields

This library provides a decorator dbcache that caches the result of your Django Model methods in your database.
Python
4
star
21

postcss-selector-lint

PostCSS Selector Lint warns about disallowed selector types in either 'global' or 'local' scope.
JavaScript
3
star
22

charts

Maykinmedia Helm Charts
Smarty
3
star
23

sdg-invoervoorziening

PDC voor de SDG (Single Digital Gateway)
Python
3
star
24

drf-polymorphic

Polymorhic support for DRF but without required models
Python
3
star
25

imvertor-lite

Convert an UML class to a JSON schema.
Python
2
star
26

objecttypes-api

API and admin interface to manage object definitions.
Python
2
star
27

django-label-loaders

Python
2
star
28

open-inwoner

Omgeving voor de inwoners van de Open Inwoner gemeenten met een focus op het sociaal domein
Python
2
star
29

django-digid-eherkenning

Django library to use DigiD or eHerkenning to authenticate users
Python
2
star
30

catalogi-importer

Easily import i-Navigator exports into the Catalogi API, such as the one in Open Zaak.
JavaScript
2
star
31

captain-hook

yarr
Shell
2
star
32

formset.js

JavaScript
2
star
33

open-personen

Basisregistratie Personen (BRP) ontsluiten middels de HaalCentraal API-standaard.
Python
2
star
34

commonground-ansible

Tools to deploy Django apps & related Common Ground components with Ansible.
Jinja
2
star
35

setup-django-backend

Re-usable composite action for Python/Django backends
2
star
36

open-klant

Registratiecomponent voor de opslag en ontsluiting van klantgegevens volgens de Klantinteracties API-specificatie.
Python
2
star
37

archiefbeheercomponent

An application for record management
Python
2
star
38

self-certifi

Create a CA-bundle based on certifi and self-signed certificates, for usage with requests.
Python
2
star
39

demo-api-component

Een voorbeeld van een OAS 3.0 API met bijbehorende referentie implementatie.
Python
1
star
40

zgw-consumers

Django app to store ZGW API configuration
Python
1
star
41

admin-ui

Our Maykin toolkit with reusable components for admin apps
TypeScript
1
star
42

bureaucracy

Template out data with (MS) Office products
Python
1
star
43

objects-api-client-django

A Django app to integrate with the Objects API
Python
1
star
44

notifications-api-common

Python
1
star
45

vng-referentielijsten

Implementatie van de referentielijsten beheerd door VNG-Realisatie
Python
1
star