Dienstag, 23. Juli 2013

Ember.js plus Bootstrap Datetimepicker

If you need to use Bootstrap Datepicker component in your Ember.js application the code shown below will help you.
  1. First of all you have to create new View object:
  2. App.DatePickerView = Ember.TextField.extend
     _valueChanged: Em.observer 'value', -> 
      value = moment(@get('value'), 'DD.MM.YYYY HH:mm')
      @$().data("DateTimePicker").setDate(value)
      return
     didInsertElement: ->  
      @$().datetimepicker
       format: 'DD.MM.YYYY HH:mm'
      return  
    
  3. And then insert it into your template:
  4.  {{view App.DateField value=mydate}}  
    
That's it!