Last active
February 6, 2016 18:12
-
-
Save TylerJPresley/f81b5007096d04805c93 to your computer and use it in GitHub Desktop.
Aurelia date picker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<adaptive-input input-class="form-control date" type="text" label="Date" value.bind="value"></adaptive-input> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {inject, bindable, bindingMode} from 'aurelia-framework'; | |
/*eslint-disable no-unused-vars*/ | |
import $ from 'jquery'; | |
import 'bootstrap'; | |
import 'datepicker'; | |
/*eslint-enable no-unused-vars*/ | |
import moment from 'moment'; | |
@inject(Element) | |
@bindable({ name: 'value', defaultValue: undefined, defaultBindingMode: bindingMode.twoWay }) | |
@bindable({ name: 'format', defaultValue: 'mm/dd/yyyy', defaultBindingMode: bindingMode.oneTime }) | |
export class DatePicker { | |
constructor(element) { | |
this.element = element; | |
} | |
attached() { | |
this.datePicker = $(this.element).find('input') | |
.datepicker({ | |
autoclose: true, | |
format: this.format, | |
//startDate: new Date(), | |
todayBtn: true, | |
todayHighlight: true | |
}); | |
this.datePicker.on('changeDate', (e) => { | |
if (e.date) { | |
this.value = moment(e.date).format('MM/DD/YYYY'); | |
} | |
}); | |
} | |
valueChanged(newValue) { | |
$(this.element).find('input').val(newValue).trigger('changeDate'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<require from="resources/components/date-picker"></require> | |
... | |
<date-picker value.bind="session.assigned_date"></date-picker> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment