donejs-select v1.1.1
donejs-select
Knockoutjs-style select for donejs
http://knockoutjs.com/documentation/options-binding.html
How to use it
- install it in your project
npm install donejs-select --save - import it in your stache file
<can-import from="donejs-select/" /> - finally insert it including the options, example:
<donejs-select
{(options)}=optionsArrayOfObject
{(selected-element-value)}=yourOwnVariable
debug=true
options-caption="choose an element:"
options-caption-separator=true
options-caption-separator-text="//////////"
options-text="text"
options-value="value"
/>NOTE: optionsArrayOfObject must be an array of objects
Assume you have:
[{text: "hello", value: 1}, {text: "good bye", value: 999}]
then the select will show "hello" and "good bye" and the selected value will be either 1 or 999
How to test it
Usage
ES6 use
With StealJS, you can import this module directly in a template that is autorendered:
import plugin from 'donejs-select';CommonJS use
Use require to load donejs-select and everything else
needed to create a template that uses donejs-select:
var plugin = require("donejs-select");AMD use
Configure the can and jquery paths and the donejs-select package:
<script src="require.js"></script>
<script>
require.config({
paths: {
"jquery": "node_modules/jquery/dist/jquery",
"can": "node_modules/canjs/dist/amd/can"
},
packages: [{
name: 'donejs-select',
location: 'node_modules/donejs-select/dist/amd',
main: 'lib/donejs-select'
}]
});
require(["main-amd"], function(){});
</script>Standalone use
Load the global version of the plugin:
<script src='./node_modules/donejs-select/dist/global/donejs-select.js'></script>Contributing
Making a Build
To make a build of the distributables into dist/ in the cloned repository run
npm install
node buildRunning the tests
Tests can run in the browser by opening a webserver and visiting the test.html page.
Automated tests that run the tests from the command line in Firefox can be run with
npm test