项目作者: westonganger

项目描述 :
Readonly support for Chosen selects
高级语言: JavaScript
项目地址: git://github.com/westonganger/chosen-readonly.git
创建时间: 2016-04-14T22:03:23Z
项目社区:https://github.com/westonganger/chosen-readonly

开源协议:MIT License

下载


chosen-readonly

NPM Version
NPM Downloads
Buy Me a Coffee

chosen-readonly is a plugin that enables the support of the readonly attribute for chosen selects.

Install

Yarn, NPM, or Bower

  1. yarn add chosen-readonly
  2. npm install chosen-readonly
  3. bower install chosen-readonly

Rails

  1. # Gemfile
  2. source 'https://rails-assets.org' do
  3. gem 'rails-assets-chosen-readonly'
  4. end
  5. # app/assets/javascripts/application.js
  6. /*
  7. *= require chosen
  8. *= require chosen-readonly
  9. */

Usage

  1. /* Makes elements readonly if they already have the readonly attribute */
  2. $('select').chosen().chosenReadonly();
  3. /* Sets all elements as readonly */
  4. $('select').chosen().chosenReadonly(true);
  5. /* Remove readonly from all elements */
  6. $('select').chosen().chosenReadonly(false);
  7. /* Anytime you want to trigger the readonly check just run */
  8. $('select').trigger('chosen:updated');

Credits

Created by Weston Ganger - @westonganger

Plugin based off off this jsFiddle by @eirc