• This repository has been archived on 04/Jan/2022
  • Stars
    star
    189
  • Rank 197,570 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

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

Repository Details

A dropdown plugin that does what you expect. (NEEDS MAINTAINER)

Dropdown.js

Finally a dropdown plugin that transforms select inputs in nice dropdowns and does not drive you crazy.

I've always wondered why the most famous plugins (Chosen and Selectize) are so huge and full of useless/pointless features? What do you need from a dropdown plugin?

Initialize it

Nice! I've found <your_fav_plugin_here> and I want to use it to style all my select inputs! But wha happens if I dinamically add a new element? I must init it manually.. Doh!

Dropdown.js get rid of this problem, in fact you just need to run the plugin one time and it will take care of every new input which matches your rules.

// Init any existing .select element and then watch for new .select elements
// added dinamically by some black magic casted by a evil wizard
$(".select").dropdown({ "autoinit" : ".select" });

Now what happens? We want our dropdowns to act like a boss.. emh like a standard select input. If it's a single select you want first element, or the selected one, already selected. We want even keyboard support, so if we press tab, it get opened and with tab you can select the options etc etc...

Style it

What else? Maybe we want to be able to style our dropdown with our own classes so that we don't have to hack the plugin to make it looks good?

$(".select").dropdown({ "dropdownClass": "my-dropdown", "optionClass": "my-option awesome" });

With this command we init every .select element (yes they are initialized always in the same way) and the my-dropdown class will be applied to the dropdown wrapper (ex: <select>) and my-option awesome will be applied to the options (ex: <option>).

Please don't fill my DOM with thousand of DIVs!!!

Don't worry friend, this is the markup used by Dropdown.js:

<div class="dropdownjs">
  <input type="text" readonly placeholder="This is a placeholder">
  <ul>
    <li value="foobar" tabindex="0">My foobar...</li>
    <li value="great" selected class="selected" tabindex="0">...is great!</li>
  </ul>
</div>

Callbacks

Psstt, ya need some callback? Dropdown.js supports callbacks, they are called on each element initialized, here an example:

$(".select").dropdown({ "callback": function($dropdown) {
  // $dropdown is the shiny new generated dropdown element!
  $dropdown.fadeIn("slow");
});

Dropdown position

Dropdowns are placed in the best position, if a select input is placed on bottom of the page, the dropdown will open above it.

Dynamically added options

You may add a new option to the select tag and it will be automatically added to the dropdown.js

Let users add options

Add data-dynamic-opts=true to the select tag to let users add or remove options.

Browserify

This library is UMD compatible, so you can use it in this way:

var jquery = require("jquery");
require("dropdown.js");

jquery.material.init();

jquery(document).ready(function() {
    $(".select").dropdown({"optionClass": "withripple"});
});
...

More Repositories

1

snackbarjs

Create Material Design snackbars and toasts with ease.
JavaScript
641
star
2

react-resize-aware

⇲👁 A simple React Hook which allows to listen the resize event of any target element when it changes sizes
JavaScript
490
star
3

react-element-queries

🐣🐷 Conditionally render pieces of UI based on element queries.
JavaScript
72
star
4

skrollr-colors

skrollr-colors is a plugin for skrollr which allow you to use mixed colors formats in skrollr's keyframes.
JavaScript
52
star
5

node-red-matter

Create Virtual Devices with Ease for the Matter Protocol!
TypeScript
34
star
6

rpi4-docker-compose-home-assistant

Dockerfile
29
star
7

bootstrap-material-design

Redirect repository
HTML
23
star
8

gist-manager

UNMAINTAINED - View and create gists within Brackets editor
JavaScript
18
star
9

spectacle-image-slide

Show a slide with a big image and a title on top
JavaScript
16
star
10

netflix

Not associated with Netflix
JavaScript
14
star
11

ama

Ask Me Anything
14
star
12

brackets-upper-titlebar

Moves the titlebar of Brackets for linux on top of the window.
CSS
7
star
13

material-design-iconfont

Material Design iconic font
CSS
7
star
14

google-assistant-mac

🚨WORK IN PROGRESS 🚨 - Bring Google Assistant on your Mac, with a Siri-like interface.
JavaScript
6
star
15

bootstrap-material-datepicker

Datepicker for bootstrap-material
HTML
5
star
16

parallax-slideshow

Simple slideshow with Parallax effect
JavaScript
4
star
17

tado-clone

Tado app clone built with React Native and Expo - works with Home Assistant
JavaScript
4
star
18

ghat

A chat with GitHub integration.
CSS
3
star
19

digital-wall

React app to show informations on TV screen
JavaScript
3
star
20

raycast-toolkit

Utilities and Components to extend the Raycast Extensions API functionalities
TypeScript
3
star
21

FezVrasta.github.io

My portfolio
HTML
2
star
22

brackets-darkbar

Stupid extension to uniform the color of the main toolbar with the rest of Brackets.
JavaScript
2
star
23

react-axe-es

react-axe, with improved support for ES modules imports
JavaScript
2
star
24

nodebb-widget-steamserverstatus

NodeBB widget to provide informations about a server which supports Steam API.
JavaScript
2
star
25

nuget-publish

Publish npm packages to NuGet using package.json
JavaScript
1
star
26

webpack-context-relative-resolver

JavaScript
1
star
27

which-pm-runs-cli

Detects what package manager executes the process from CLI
JavaScript
1
star
28

eslint-plugin-no-iife

ESLint plugin to disallow IIFE
JavaScript
1
star
29

graphql-relay-cross-tab-sync

TypeScript
1
star