Selectize.js

repository·master·Indexed 12 days ago

https://github.com/selectize/selectize.js

An 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.

Tokens
17.1K
Snippets
78
Records
113
Agent score
93%

What's inside Selectize

  1. Selectize dependencies and requirements

    master

    Before 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.
  2. How the Selectize plugin system works

    master

    Selectize 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 the setup() method if your plugin needs to attach event listeners to the control's DOM elements.
  3. Selectize Glossary and Core Concepts

    master

    Understanding the terminology used in Selectize:

    • Config/configuration: The initial settings provided during initialization.
    • Settings: The current settings of a Selectize instance, accessible via the setting property 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 sortField or searchField) are used for internal logic.
    • Items: The list of currently selected values (the chosen option values).
  4. Deploy the website

    master

    The website can be deployed using different methods depending on your environment:

    Using SSH: Set the USE_SSH environment variable to true.

    Using GitHub Pages (Non-SSH): Provide your GitHub username via the GIT_USER environment variable. This command builds the website and pushes it to the gh-pages branch.

    # Deploy using SSH
    $ USE_SSH=true yarn deploy
    
    # Deploy to GitHub Pages
    $ GIT_USER=<Your GitHub username> yarn deploy
  5. Install Selectize via CDN

    master

    The 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>
  6. Understand the Selectize license and usage guidelines

    master

    Selectize 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.
  7. Group options in the dropdown menu using Option Groups

    master

    Selectize 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
    });