cars10 / pick-me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PickMe

PickMe is customizable html select picker written in pure javascript.

  1. Usage
  2. API
  3. Development
  4. Production
  5. TODO

Development

  1. make build
  2. make dev
  3. http://localhost:8000

Usage

HTML

<select name="picker" id="picker">
    <option value>Please select</option>
    <option value="1" selected>Abbey Storrs</option>
</select>

JS

new PickMe({id: 'picker'})

API

PickMe registers a global window.PickMe object that lets you access each initialized select. You can get each instance by using its id:

window.PickMe.elements // or just PickMe.elements
// => {'picker-single': PickMe}

window.PickMe.elements['picker-single']
// => PickMe {..}

Working on this object you can use any method and read any property that PickMe uses, but the only useful methods to call externally are the following:

method example description
destroy PickMe.elements['picker'].destroy() Destroys the added dom elements and event handlers. Resets the select to it's state before pick-me was initialized.
reload PickMe.elements['picker'].reload() Same as destroy, but re-initializes the element automatically.

Call a method directly:

window.PickMe.elements['picker-single'].reload()

About


Languages

Language:TypeScript 80.6%Language:CSS 9.5%Language:HTML 8.2%Language:JavaScript 0.8%Language:Makefile 0.6%Language:Dockerfile 0.3%