decide.nolog.cz/app/views/datepicker.js
jelhan 016ccfc31c rewritten option and input field relationship
keep inputs while setting up poll and update options based on inputs by observer
2014-11-21 12:24:24 +01:00

36 lines
No EOL
857 B
JavaScript

export default Em.View.extend({
classNames: ['datepicker'],
didInsertElement: function() {
var self = this;
this._super();
$('.datepicker').datepicker({
format: "yyyy-mm-dd hh:mm:ss",
multidate: true,
multidateSeparator: ";",
calendarWeeks: true,
todayHighlight: true,
language: this.get('controller.language.selected')
})
// bind date changes to option array in model
.on('changeDate', function(e){
var dates = e.dates,
newDates = [];
// sort dates
dates.sort(function(a,b){
return new Date(a) - new Date(b);
});
// get array in correct form
dates.forEach(function(option) {
newDates.pushObject({title: option});
});
// set options
self.set('_parentView.controller.optionsDates', newDates);
});
}
});