Socket
Socket
Sign inDemoInstall

dropdown

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dropdown

DOM mechanism for filling and navigating a dropdown


Version published
Weekly downloads
295
increased by42.51%
Maintainers
1
Install size
12.6 kB
Created
Weekly downloads
 

Readme

Source

dropdown

Dropdown helper.

Usage

<input id="query" autocomplete="off">
<script>
  var query_el = document.getElementById('query');
  var dropdown = Dropdown.attach(query_el)
    .on('change', function(query) {
      // suppose query == 'ch'
      $.getJSON('/search', {q: query}, function(data, textStatus, jqXHR) {
        // data looks like [{label: 'Charles', value: 'Charles'}, {label: 'Chris', value: 'chris'}, ...]
        dropdown.setOptions(data);
      });
    })
    .on('select', function(value) {
      query_el.value = value;
    });
</script>
<style>
  .dropdown {
    margin: 0 2px;
    padding: 0;
    list-style: none;
    border: 1px solid #CCC;
  }
  .dropdown li {
    padding: 1px;
    cursor: default;
  }
  .selected {
    background-color: pink;
  }
</style>

TODO

  • keep track of mouseover vs. up-down arrow selection, and revert to keyed up-down selection on mouseout.

License

Copyright 2011-2014 Christopher Brown. MIT Licensed.

Keywords

FAQs

Last updated on 20 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc