1.2.2 • Published 6 years ago

bootstrap-hardskilled-extend-select v1.2.2

Weekly downloads
14
License
MIT
Repository
github
Last release
6 years ago

Extended Select for Bootstrap 4 (analog bootstrap-select)

release version npm version npm.io License: MIT dependences devDependences

Demo and documentation

You can require bootstrap plugin via cdn or download the archive with release and unzip into assets directory.

For install via npm, use command:

npm i --save bootstrap-hardskilled-extend-select

To use CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-hardskilled-extend-select@latest/css/select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-hardskilled-extend-select@latest/js/select.min.js"></script>

Example usage:

<link rel="stylesheet" href="css/select.min.css">
<script src="js/select.min.js"></script>
<script>
    $('select').extendSelect();
</script>

Usage with options:

<link rel="stylesheet" href="css/select.min.css">
<script src="js/select.min.js"></script>
<script>
    $('select').extendSelect({
        // Search input placeholder:
        search: 'Find',
        // Title if option not selected:
        notSelectedTitle: 'Pls select',
        // Message if select list empty:
        empty: 'Empty',
        // Class to active element:
        activeClass: 'active',
        // Class to disabled element:
        disabledClass: 'disabled',
        // Custom error message for all selects (use placeholder %items):
        maxOptionMessage: 'Max %items elements',
        // Delay to hide message
        maxOptionMessageDelay: 2000,
        // Popover logic (resize or save height):
        popoverResize: true,
        // Auto resize dropdown by button width:
        dropdownResize: true
    });
</script>
KeyDescriptionDefault value
searchSearch input placeholderSearch
notSelectedTitleTitle if option not selectedNothing to shown
emptyMessage if select list emptyNothing to shown
activeClassClass to active elementactive
disabledClassClass to disabled elementdiabled
maxOptionMessageCustom error message for all selects (use placeholder %items)Limit reached (%items items max)
maxOptionMessageDelayDelay to hide message2000
popoverResizePopover logic (resize or save height)false
dropdownResizeAuto resize dropdown by button widthfalse

To listen changes use .on('change') event:

$('select#basic').on('change', function () {
    const selected = $(this).find(':selected').text();
    $('#basicResult').text('Selected: ' + selected)
})

HTML attributes to select:

<select 
    id="extendedSelect" 
    class="form-control" 
    data-live-search="true"
    data-max-options="2"
    data-max-options-message="Max items"
    data-live-search-placeholder="Find"
    data-hide-disabled="true"
    data-btn-class="btn-danger btn-block"
    data-input-group="true"
    data-not-selected="Select is empty"
    data-empty="Items not found"
    data-type="checkbox"
    multiple
>
    <option selected>Rabbit</option>
    <option>Cat</option>
    <option class="get-class" disabled>Owl</option>
    <optgroup label="test" data-subtext="another test">
        <option>Spider</option>
        <option selected>Worm</option>
        <option>Fly</option>
    </optgroup>
</select>
AttributeDescriptionDefault value
data-live-searchLive searchfalse
data-max-optionsMax selected optionsNothing to shown
data-max-options-messageMessage if select limit overflowLimit reached (%items items max)
data-live-search-placeholderSearch input placeholderSearch
data-hide-disabledHide disabled elementsfalse
data-btn-classButton class for dropdownbtn-secondary
data-not-selectedTitle if option not selectedNothing to shown
data-emptyMessage if select list emptyNothing to shown
data-typeCustom select type (ex. checkbox)null
multipleEnable multiple selectionsfalse

Hire us via Upwork! | Our website

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago