Completely basic styled form selects to give developers the freedom to customize form selects for their projects
npm install naked-form-selectnpm install naked-form-selectnakedFormSelect('select') has the multiple property, ex) data-multiple-keyword to in order to control the verbiage used in the label when multiple options are selected. For example:```
If option 1 is selected, the label will read 'Option 1'. However, if Option 1 and 2 are selected, the label will read '2 donuts selected'. The keyword provided is turned plural so I recommend that you enter in the singular version of your noun.
#### data-label
Add data-label="true" to any select (single or multiple) in order to set the default verbiage in the label to the text content to the first option but while excluding the first option from the dropdown itself. For example:``
Will result in an output that looks like this (the following is not the exact markup generated by naked form select, it is simplified for the example):
``
Enable keyword search for your select by the following example:
``
nakedFormSelect('select', {
keywordSearch: {
on: true,
placeholder: 'Enter keyword'
}
});
nakedFormSelect('select', {
submitBtn: {
on: true,
text: 'Submit this form'
}
});
`
It will submit the parent form.$3
Query target select elements within a certain context. This option accepts both a value and a boolean property to query document. For instance, reference
Example #4 in the demo.html file. If you want to initialize select elements with a class of .example-4 within a containing element with a class of .section-with-context, you would do so like this:
`
nakedFormSelect('.example-4', {
context: {
value: '.section-with-context',
queryDocument: true
}
});
`
This essentially accomplishes what the context parameter in jQuery selectors does.I specifically created the 'queryDocument' option for the Drupal projects I work on to take advantage of the context variable paired with Drupal Behaviors.
So, if this option is turned on (default is 'false'), context.value will be queried intead of document.
$3
`
{
context = {
value: undefined,
queryDocument: false
},
keywordSearch = {
on: false,
placeholder: undefined
},
submitBtn = {
on: false,
text: undefined
}
}
``Licensed under the MIT license.