webcito/bs-select-drop
Composer 安装命令:
composer require webcito/bs-select-drop
包简介
Converts a select into a dropdown
README 文档
README
Important
This package has been overhauled and has been revised here https://github.com/ThomasDev-de/bs-select
jquery-bsSelectDrop
Converts a select into a dropdown
table of contents
Requirements
- bootstrap >=5.0
- jQuery 3.6
Installation
Download and include the script at the end of the body tag.
<script src="jquery.bsSelectDrop.js" type="text/javascript">
or install with composer and include the script at the end of the body tag.
composer require webcito/bs-select-drop:dev-main
<script src="/vendor/webcito/bs-select-drop/dist/jquery.bsSelectDrop.js" type="text/javascript">
Set global defaults
// multiple options $.bsSelectDrop.setDefaults(options); // single option $.bsSelectDrop.setDefault(prop, val); // get default options $.bsSelectDrop.getDefaults();
Usage
All selects with the attribute [data-bs-toggle="select"] are initialized automatically.
<!-- Simple selection --> <select name="countries"> <option value="Germany">Deutschland</option> <option value="Poland">Polen</option> ... </select> <!-- Or multiselection --> <select name="cities" multiple> <option value="1">Berlin rocks</option> <option value="2">New York</option> ... </select> <!-- Or with option groups --> <select name="cities2" multiple> <optgroup label="Germany"> <option value="1">Berlin</option> <option value="2">Munich</option> </optgroup> <optgroup label="USA"> <option value="3">New York</option> <option value="4">San Francisco</option> </optgroup> <optgroup label="Spain"> <option value="5">Barcelona</option> <option value="6">Madrid</option> </optgroup> ... </select> <script> $('select').bsSelectDrop(); </script>
option[data-attributes]
| data-attribute | example | description |
|---|---|---|
| data-subtext | <option data-subtext="Germany" value="1">Berlin</option> |
Adds a small additional text section |
| data-icon | <option data-icon="fa-solid fa-city" value="1">Berlin</option> |
Adds an icon in front of the option. (e.g. a class from FontAwesome) |
Options
| property | type | default | desc |
|---|---|---|---|
| btnWidth | string |
fit-content |
the css width of the dropdown button |
| btnEmptyText | string |
Please select.. |
The text at no selection |
| btnClass | string |
btn btn-outline-secondary |
The classes assigned to the dropdown button |
| dropUp | bool |
false |
shows the menu above |
| dropStart | bool |
false |
shows the menu on the left |
| dropEnd | bool |
false |
shows the menu on the right |
| dropCenter | bool |
false |
shows the menu centered |
| dropHeaderClass | string |
secondary |
If option groups are present, the background class of the heading is set here. |
| search | bool |
true |
adds a search function to the menu |
| darkMenu | bool |
false |
shows the menu in darkstyle |
| menuPreHtml | null/string |
null |
shows a text in the menu before the selection |
| menuAppendHtml | null/string |
null |
shows the text in the menu after the selection |
| showSubtext | bool |
true |
If this option is true, options have the data attribute data-subtext, the subtext will be displayed in the dropdown. |
| showActionMenu | bool |
true |
If it is a multiple selection and this option is true, two buttons are displayed above the selection for faster selection. |
| showSelectionAsList | bool |
true |
If it is a multiple selection, all selections should be listed below each other. If the value is false, it will show how much was selected. |
| showSelectedText | function |
(selectedItems, totalItems) => {} |
If it is a multiple selection and the selected elements are greater than 1, this function is called. This function is ignored if the showSelectionAsList option is true. |
| deselectAllText | string |
Deselect All |
If showActionMenu is true, the language of the two buttons can be set here. |
| selectAllText | string |
Select All |
If showActionMenu is true, the language of the two buttons can be set here. |
| dropDownListHeight | number |
300 |
Height of the dropdown list. |
| selectIconClass | string |
`` | Class used to style the select icon. |
| selectIcon | string |
`` | Icon used for selection (i.e ) |
| debug | bool |
false |
If true then outputs debug messages to the console. |
| dropDownItemClass | string |
`` | Class used to stype the drop-down item. Add and .active style to override the Bootstrap active styling |
| searchPlaceholder | string |
Search.. |
"Placeholder for search input box* |
Methods
Methods are called as follows
$('select').bsSelectDrop('method', param);
show
Opens the dropdown
$('select').bsSelectDrop('show');
hide
Closes the dropdown
$('select').bsSelectDrop('hide');
val
Changes the value of the select
$('select').bsSelectDrop('val', 1);
updateOptions
Changes the options of the dropdown.
$('select').bsSelectDrop('updateOptions', { buttonClass: 'btn btn-danger', ... });
refresh
Rebuild the dropdown. This is useful if the options are changed via Javascript.
$('select').bsSelectDrop('refresh');
destroy
Deletes the dropdown and restores the original select.
$('select').bsSelectDrop('destroy');
Events
| event type | Description |
|---|---|
| hide.bs.select | Fires immediately when the hide instance method has been called. |
| hidden.bs.select | Fired when the dropdown has finished being hidden from the user and CSS transitions have completed. |
| show.bs.select | Fires immediately when the show instance method is called. |
| shown.bs.select | Fired when the dropdown has been made visible to the user and CSS transitions have completed. |
| refresh.bs.select | Fires when the refresh method has been invoked. |
| change.bs.select | Fires when the method val has been called. |
| update.bs.select | Fires when the method updateOptions was called. |
| destroy.bs.select | Fires when the destroy method has been activated. |
webcito/bs-select-drop 适用场景与选型建议
webcito/bs-select-drop 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jquery」 「bootstrap」 「select」 「dropdown」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webcito/bs-select-drop 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webcito/bs-select-drop 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webcito/bs-select-drop 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP behavior plugin for easily generating some complicated queries like (bulk) insert/upsert etc.
PHP PDO Mysql select statement iterator implemented as multiple queries using LIMIT clauses
PHP library that allows linking queries from diferent physical databases using mysql pdo database connections
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Country select field type.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-02-18