Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/westonganger/chosen-readonly

Readonly support for Chosen selects
https://github.com/westonganger/chosen-readonly

chosen form readonly select

Last synced: 8 days ago
JSON representation

Readonly support for Chosen selects

Awesome Lists containing this project

README

        

# 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
```
yarn add chosen-readonly

npm install chosen-readonly

bower install chosen-readonly
```

#### Rails
```ruby
# Gemfile
source 'https://rails-assets.org' do
gem 'rails-assets-chosen-readonly'
end

# app/assets/javascripts/application.js
/*
*= require chosen
*= require chosen-readonly
*/
```

# Usage
```javascript
/* Makes elements readonly if they already have the readonly attribute */
$('select').chosen().chosenReadonly();

/* Sets all elements as readonly */
$('select').chosen().chosenReadonly(true);

/* Remove readonly from all elements */
$('select').chosen().chosenReadonly(false);

/* Anytime you want to trigger the readonly check just run */
$('select').trigger('chosen:updated');
```

# Credits
Created by Weston Ganger - @westonganger

Plugin based off off [this jsFiddle](http://jsfiddle.net/eirc/v2es7L8o/) by @eirc