Skip to content

Commit

Permalink
Merge branch 'feature/basic-combo-box'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfox committed Sep 2, 2015
2 parents 3a47a75 + 5546516 commit 48281d2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/combo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<div class="form-group">
<label for="lookupField" class="control-label">${title}</label>
<select class="form-control">
<option repeat.for="option of options" value="${option.value}" selected.one-time="$parent.selected === option.value">${option.description}</option>
</select>
</div>
</template>
38 changes: 38 additions & 0 deletions src/combo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {customElement, inject, bindable, bindingMode} from 'aurelia-framework';

@customElement('combo')
@bindable({
name:'title',
attribute:'title',
defaultBindingMode: bindingMode.oneTime
})
@bindable({
name:'options',
attribute:'options',
defaultBindingMode: bindingMode.oneTime
})
@bindable({
name:'selected',
attribute:'selected',
defaultBindingMode: bindingMode.twoWay
})
@inject(Element)
export class Combo {
constructor(element) {
this.element = element;
this._boundChange = this._change.bind(this);
}

attached() {
this.combo = this.element.querySelector('select');
this.combo.addEventListener('change', this._boundChange);
}

detached() {
this.combo.removeEventListener('change', this._boundChange);
}

_change(change) {
this.selected = change.target.value;
}
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function configure(aurelia) {
aurelia.globalResources(['lookup-widget','autocomplete-widget']);
aurelia.globalResources(['lookup-widget','autocomplete-widget', 'combo']);
}
4 changes: 2 additions & 2 deletions src/lookup-widget.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>

<div class="form-group">
<label for="lookupField" class="control-label">${title}</label>
<input type="text" id="lookupField">

</div>
</template>

0 comments on commit 48281d2

Please sign in to comment.