https://github.com/optimalbits/gnd-dropdown
A Gnd dropdown component
https://github.com/optimalbits/gnd-dropdown
Last synced: 8 months ago
JSON representation
A Gnd dropdown component
- Host: GitHub
- URL: https://github.com/optimalbits/gnd-dropdown
- Owner: OptimalBits
- License: mit
- Created: 2013-08-24T07:48:38.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2015-02-04T19:40:39.000Z (over 11 years ago)
- Last Synced: 2025-01-27T15:05:10.663Z (over 1 year ago)
- Language: TypeScript
- Size: 254 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gnd-dropdown
============
A dropdown (as html select) component for Gnd.
It supports binding a collection to the options and a model to the current
selection.
Install
=======
npm install gnd-dropdown
Usage
=====
In a nodejs server:
var Dropdrown = require('gnd-dropdown');
// Dropdown.build points to the directory with the files to server
// using connect / express
app.use(static(path.join(__dirname, Dropdown.build)))
In the client:
// simple collection
var dropdown = new Dropdown(myCollection, {
selectedId: mySelectedId,
parent: '#dropdown'
});
dropdown.render();
// binding the selected item id to some model property
var dropdown = new Dropdown(myCollection, {
selection: {model: myModel, key: 'itemId'},
parent: '#dropdown'
});
dropdown.render();
// Listen to changes
dropdown.on('selected:', function(item){
console.log(item);
});
// Do something special when last element is deleted
dropdown.on('lastRemoved:', function(item){
// ---
})