nice-select2
nice-select2 copied to clipboard
add instance.getValue() and instance.setValue(newVal)
instance.setValue(newVal)
//-- regular select
newVal = 'foo';
//-- selected foo and bar option for multiple
newVal = ['foo','bar'];
source SELECT tag will also change its value and highlight following newVal
currentVal = instance.getValue()
- currentVal is string if not multiple select
- currentVal is Array like ['foo','bar'] or ['boo'] for multiple select
Summary by Sourcery
Add methods to set and get the value of the select element, enhancing the functionality to support both single and multiple selections.
New Features:
- Introduce instance.setValue(newVal) method to set the value of the select element, supporting both single and multiple selections.
- Introduce instance.getValue() method to retrieve the current value of the select element, returning a string for single selections and an array for multiple selections.
Reviewer's Guide by Sourcery
This pull request introduces two new methods, setValue and getValue, to the NiceSelect class. The setValue method allows for programmatically setting the value of the select element, while the getValue method retrieves the current value. Additionally, the handling of selected options has been improved in the _onItemClicked and resetSelectValue methods to ensure more robust manipulation of the 'selected' attribute.
File-Level Changes
| Files | Changes |
|---|---|
src/js/nice-select2.js |
Enhanced the NiceSelect class with new methods for setting and getting the value of the select element, and improved the handling of selected options. |
Tips
- Trigger a new Sourcery review by commenting
@sourcery-ai reviewon the pull request. - Continue your discussion with Sourcery by replying directly to review comments.
- You can change your review settings at any time by accessing your dashboard:
- Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
- Change the review language;
- You can always contact us if you have any questions or feedback.