Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreivictor/select2-dropdownposition
Extends Select2 plugin by adding an option to set the position of the dropdown
https://github.com/andreivictor/select2-dropdownposition
select2
Last synced: 2 months ago
JSON representation
Extends Select2 plugin by adding an option to set the position of the dropdown
- Host: GitHub
- URL: https://github.com/andreivictor/select2-dropdownposition
- Owner: andreivictor
- Created: 2018-01-26T17:48:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-30T17:19:50.000Z (over 2 years ago)
- Last Synced: 2024-05-21T06:13:35.670Z (7 months ago)
- Topics: select2
- Language: JavaScript
- Size: 3.91 KB
- Stars: 12
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# select2 - 'dropdownPosition' option
Extends Select2 v4 plugin by adding an option to set the position of the dropdown.
## Description ##
Select2 automatically places the dropdown, either above or below the element.
In some cases (e.g. mobile devices) it can be a better experience to force the dropdown to a certain position.This feature was already discussed in the official plugin repository (https://github.com/select2/select2/issues/2710), but hasn't been included yet.
The new `dropdownPosition` can take the following values:
- `auto` (default) - it uses the old behavior, placing the dropdown either above or below the element, depending on available space,
- `below` - the dropdown is always displayed below the element;
- `above` - the dropdown is always displayed above the element.
## Setup ##
Include the script after Select2 main javascript file:
```html```
## Usage ##
Initialize the select2 plugin with the `dropdownPosition` option set to `above` or `below`:```javascript
$("select").select2({
// other options
dropdownPosition: 'below'
});
```## Demo ##
Demo available on [JsFiddle](https://jsfiddle.net/byxj73ov/).