Javascript 以编程方式重置选择

Javascript 以编程方式重置选择,javascript,ember.js,Javascript,Ember.js,我想重置(提示)控制器中的选择。select将更改为提示值,但仅当我手动重置时,才会显示整个列表 App.IndexController = Ember.Controller.extend(Ember.Validations.Mixin, { selectedCountry: null, selectedNumber: null, actions: { submit: function() { alert('Saved!'); console.log(

我想重置(提示)控制器中的选择。select将更改为提示值,但仅当我手动重置时,才会显示整个列表

App.IndexController = Ember.Controller.extend(Ember.Validations.Mixin, {
  selectedCountry: null,
  selectedNumber: null,
  actions: {
    submit: function() {
      alert('Saved!');
      console.log(this.name);
      console.log(this.country_list);
    },
    resetForm:function(){
      console.log('try to reset form');
      this.set('selectedCountry',null);
      this.set('selectedNumber',null);
    }    
  },

  countries : [
    {id:'1',name:'Sierre Leone'},
    {id:'2',name:'Japan'}

  ],
    numbers : [
    {id:'1',name:'234'},
    {id:'2',name:'674'}

  ],
    list : [
    {id:'1',name:'Sierre Leone',nr:'234'},
    {id:'2',name:'Japan',nr:'674'},
    {id:'3',name:'Sierre Leone',nr:'934'},
    {id:'4',name:'Japan',nr:'243'}
  ],

  filtered: (function() {
    var temp = this.get('list');
    if (this.get('selectedCountry') !== null) 
      temp = temp.filterProperty('name', this.get('selectedCountry'));
    if (this.get('selectedNumber') !== null) 
      temp = temp.filterProperty('nr', this.get('selectedNumber'));

    return temp;
  }).property('selectedCountry','selectedNumber')
});
这是JsBin

我不知道我是否理解正确,但如果您想将选择选项重置为初始状态,请尝试设置
this.set('selectedCountry',null)