Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added readOnly attribute. fix #181 #182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions addon/components/ember-selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ export default Component.extend({
onBlur: this._registerAction('on-blur'),
onFocus: this._registerAction('on-focus'),
onInitialize: this._registerAction('on-init'),
onClear: this._registerAction('on-clear')
onClear: this._registerAction('on-clear'),
onDelete: run.bind(this, '_onDelete'),
};

var generalOptions = ['delimiter', 'diacritics', 'createOnBlur',
Expand All @@ -237,7 +238,7 @@ export default Component.extend({
'closeAfterSelect', 'allowEmptyOption',
'scrollDuration', 'loadThrottle', 'preload',
'dropdownParent', 'addPrecedence', 'selectOnTab',
'searchField'];
'searchField', 'readOnly'];

generalOptions.forEach((option) => {
options[option] = this.getWithDefault(option, options[option]);
Expand Down Expand Up @@ -314,8 +315,14 @@ export default Component.extend({
args.unshift(action);
this.sendAction.apply(this, args);
});
},
},

/**
* Event callback that is triggered when user press backspace, or delete
*/
_onDelete() {
return this.get("readOnly") !== true;
},
/**
* Event callback that is triggered when user types in the input element
*/
Expand Down