当我使用bootstrap datepicker时,为什么Ember.js会丢失valueBinding?

Joe*_*l T 7 handlebars.js twitter-bootstrap ember.js

我注意到在我的应用程序中,当我使用下面的代码时,我在日期选择器小部件中给出了格式化日期,但是当我单击搜索时,控制台显示空字符串.但是,如果我删除该didInsertElement方法,我将丢失datepicker弹出窗口,但数据绑定仍然存在,控制台显示我输入的日期.

在我的车把模板中

{{view App.DateField valueBinding="controller.startDate" classNames="startDate"}}
{{view App.DateField valueBinding="controller.endDate" classNames="endDate"}}
<button {{action "search" target='controller'}}>Search</button>
Run Code Online (Sandbox Code Playgroud)

在我的应用程序中

App.ApplicationController = Ember.ArrayController.extend({
  search: function() {
    console.log(this.get('startDate'));
    return console.log(this.get('endDate'));
  }
});

App.DateField = Ember.TextField.extend({
  didInsertElement: function() {
    return this.$().datepicker();
  }
});
Run Code Online (Sandbox Code Playgroud)

任何想法,为什么我设置时丢失了数据绑定didInsertElement

版本: bootstrap-datepicker,

handlebars-1.0.0-rc.3
ember-1.0.0-rc.3
jQuery 1.9.1
Run Code Online (Sandbox Code Playgroud)

Mat*_*son 10

我认为问题在于,datepicker和ember都看到了以不同方式改变的价值.看看这个:

  App.DateField = Ember.TextField.extend(
    didInsertElement: ->
      @.$().datepicker().on 'changeDate', =>
        @.$().trigger('change')
  )
Run Code Online (Sandbox Code Playgroud)

当窗口小部件更改事件触发时,如果您转向并触发元素上的更改事件,则Ember应注册绑定已更新的事实.