Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/westonganger/chosen-readonly
- Owner: westonganger
- License: mit
- Created: 2016-04-14T22:03:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-30T16:48:48.000Z (over 5 years ago)
- Last Synced: 2024-12-23T01:04:22.004Z (19 days ago)
- Topics: chosen, form, readonly, select
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
`chosen-readonly` is a plugin that enables the support of the readonly attribute for chosen selects.
# Install
#### Yarn, NPM, or Bower
```
yarn add chosen-readonlynpm 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 - @westongangerPlugin based off off [this jsFiddle](http://jsfiddle.net/eirc/v2es7L8o/) by @eirc