Skip to content

Commit

Permalink
Merge pull request #453 from MaximBalaganskiy/patch-2
Browse files Browse the repository at this point in the history
feat(select): add readonly
  • Loading branch information
Thanood authored Jul 13, 2017
2 parents 2100f1a + 5f63bfc commit a36ec64
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import {DOM} from 'aurelia-pal';
@customAttribute('md-select')
export class MdSelect {
@bindable() disabled = false;
@bindable() readonly = false;
readonlyChanged() {
if (this.readonly) {
this.makeReadonly($(this.element).siblings('input')[0]);
} else {
this.refresh();
}
}

@bindable() enableOptionObserver = false;
@bindable() label = '';
@bindable() showErrortext = true;
Expand Down Expand Up @@ -144,6 +153,16 @@ export class MdSelect {
this.observeVisibleDropdownContent(true);
this.observeOptions(true);
this.setErrorTextAttribute();
if (this.readonly) {
this.makeReadonly(input[0]);
}
}

makeReadonly(input) {
$(input).off('click');
$(input).off('focus');
$(input).off('keydown');
$(input).off('open');
}

observeVisibleDropdownContent(attach) {
Expand Down

0 comments on commit a36ec64

Please sign in to comment.