Example: Building a date input field

Missed that you wanted to be able to set date. Then try this:

App.DateField = Ember.TextField.extend({
  type: 'date',
  date: function(key, date) {
    if (date) {
      this.set('value', date.toISOString().substring(0, 10));
    } else {
      value = this.get('value');
      if (value) {
        date = new Date(value);
      } else {
        date = null;
      }
    }
    return date;
  }.property('value')
});

See example at http://jsbin.com/ulapuf/6/edit

3 Likes