Selectize.js
repository·master·Indexed 12 days ago
https://github.com/selectize/selectize.jsAn extensible, jQuery-based custom <select> UI control used to enhance standard select elements. It is ideal for complex input needs such as tagging, contact lists, and remote data loading. Version 0.15.2 requires jQuery 1.7 or greater.
What's inside Selectize
- MicroPlugin is a lightweight, modular plugin architecture designed to make JavaScript libraries extensible. It allows developers to create plugins that can declare dependencies on other plugins and be initialized with various configuration options. It is provided as a global class.
Privacy policy for the Selectize library
masterThe Selectize library itself does not collect any personal information or send/receive any telemetry data.
This privacy policy applies exclusively to the Selectize documentation website (https://selectize.dev). If you are using the library in your own application, it does not perform any data collection or tracking as part of its core functionality.
Selectize dependencies and requirements
masterBefore using Selectize, ensure you meet the following requirements:
- jQuery: Selectize requires jQuery to function.
- jQuery UI: Required only if you intend to use the Drag & Drop plugin.
- Styles: The library includes Bootstrap styles and provides raw Less and Sass files for customization with other frameworks.
How the Selectize plugin system works
masterSelectize uses the microplugin interface to allow features to be added without modifying the core library. This system is designed to be lean and provides developers with complete control over the plugin lifecycle.
Key lifecycle details:
- Initialization: Plugins are initialized immediately before the control is set up.
- DOM Access: Because control elements are created during the
setup()phase, you must override thesetup()method if your plugin needs to attach event listeners to the control's DOM elements.
Selectize Glossary and Core Concepts
masterUnderstanding the terminology used in Selectize:
- Config/configuration: The initial settings provided during initialization.
- Settings: The current settings of a Selectize instance, accessible via the
settingproperty of the Selectize object. - Options: The list of objects available to select.
- Each object requires a unique value (defined by
valueField) to identify it. - Each object requires a label to display (defined by
labelField). - Other properties (like
sortFieldorsearchField) are used for internal logic.
- Each object requires a unique value (defined by
- Items: The list of currently selected values (the chosen option values).
Use the Drag & Drop plugin
masterThe Drag & Drop plugin allows users to rearrange selected items within a Selectize instance by dragging them.
Requirement: This plugin requires jQuery UI (sortable) to function. Ensure jQuery UI is loaded in your environment before initializing the plugin.
Use the Option Group Columns plugin
masterTheopt-group-colplugin, created by Simon Hewitt, allows you to render option groups horizontally. It enhances the user experience by providing convenient left/right keyboard navigation between columns of options.Deploy the website
masterThe website can be deployed using different methods depending on your environment:
Using SSH: Set the
USE_SSHenvironment variable totrue.Using GitHub Pages (Non-SSH): Provide your GitHub username via the
GIT_USERenvironment variable. This command builds the website and pushes it to thegh-pagesbranch.# Deploy using SSH $ USE_SSH=true yarn deploy # Deploy to GitHub Pages $ GIT_USER=<Your GitHub username> yarn deployRun Selectize tests
masterTo ensure all functional and unit tests pass, run:
npm run testTo run tests against specific browsers (e.g., Firefox, Chrome, Safari), use the
BROWSERSenvironment variable:BROWSERS=Firefox,Chrome,Safari npm testInstall Selectize via CDN
masterThe fastest way to add Selectize to your project is to include the JavaScript and CSS files directly from cdnjs. Ensure you include the CSS before the JavaScript.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/css/selectize.default.min.css" integrity="sha512-pTaEn+6gF1IeWv3W1+7X7eM60TFu/agjgoHmYhAfLEU8Phuf6JKiiE8YmsNC0aCgQv4192s4Vai8YZ6VNM6vyQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.15.2/js/selectize.min.js" integrity="sha512-IOebNkvA/HZjMM7MxL0NYeLYEalloZ8ckak+NDtOViP7oiYzG5vn6WVXyrJDiJPhl4yRdmNAG49iuLmhkUdVsQ==" crossorigin="anonymous" referrerpolicy="no-referrer" ></script>Understand the Selectize license and usage guidelines
masterSelectize is licensed under the Apache License, Version 2.0. It is free to use for any purpose, including commercial projects, private use, and modification. You may also distribute projects containing Selectize under different or proprietary licenses.
Usage Guidelines
While free to use, the following guidelines are suggested for commercial users:
- Consider making a donation to fund development.
- Consider becoming a sponsor to receive benefits like priority support.
Compliance Requirements
If you redistribute Selectize or derivative works, you must:
- Include the full license text in any distribution.
- Include all original copyright notices.
- State any changes you have made to the source code.
Restrictions
You cannot:
- Use the 'Selectize' name in any trademarks.
- Use the 'Selectize' name in a way that implies endorsement by the Selectize project.
- Hold the Selectize project or its contributors liable for any damages.
Group options in the dropdown menu using Option Groups
masterSelectize allows you to organize options into logical groups within the dropdown menu. This is useful for categorizing long lists of items, making them easier for users to navigate.
// Concept demonstration: Grouping options in Selectize $('#select-ize-opt-groups').selectize({ // Options are typically structured with a 'optgroup' property // or via specific data formats to enable grouping });