2014-08-28 57 views
0

今天我尝试更新我的应用程序以支持1.7.0,但我注意到视图中的操作处理程序停止了被调用。视图中的Ember操作在版本1.7.0中停止工作

我的观点定义如下:

// Ember view for the project partial 
App.ProjectThumbnailView = Ember.View.extend({ 
    templateName: 'partials/_project', 
    didInsertElement: function() {...}, 

    /** 
    * Handles the event when the 'feature project' button is pressed 
    * @param {Project} project The project to be featured 
    */ 
    featureProject: function() { 
    var project = this.get('context'); 
    project.toggleProperty('featured'); 
    project.toggleProperty('abilities.feature'); 
    project.toggleProperty('abilities.unfeature'); 
    project.feature() 
     .then(
      function() {}, 
      function(error) { 
       project.toggleProperty('featured'); 
       project.toggleProperty('abilities.feature'); 
       project.toggleProperty('abilities.unfeature'); 
       App.set('error', { 
        message: I18n.t('error_message_generic_server') 
       }); 
      } 
    ); 
    } 
}); 

模板的谐音/ _project.hbs包含以下按钮来调用动作:

<button class="btn btn-mini btn-primary right-top" {{action 'featureProject' target='view'}}><i class="icon-star"></i> {{unbound i18n 'feature'}}</button> 

我也试图把里面的的featureProject行动行动哈希无济于事。

这用于在1.6.0版本和之前的1.6版本中完美工作。有什么我失踪了吗?

谢谢。

+0

你可以把一个bin显示出来吗?我做了一个箱子,它似乎工作正常。请参阅http://emberjs.jsbin.com/meqef/1/edit – tikotzky 2014-08-28 13:00:58

+0

问题是,我的项目真的很大,我似乎无法用一小部分代码来重现错误,因为环境不同(模块等等,...)。 – rtemperv 2014-08-29 07:18:09

+0

嗯....这将是棘手追查。 – tikotzky 2014-08-29 22:03:03

回答

1

您应该在actions哈希中采取行动。 Ember 1.7.0删除了对查找控制器根对象中的操作的支持。这已被使用一段时间了。

// Ember view for the project partial 
App.ProjectThumbnailView = Ember.View.extend({ 

    actions: { 
     /** 
     * Handles the event when the 'feature project' button is pressed 
     * @param {Project} project The project to be featured 
     */ 
     featureProject: function() { 
     var project = this.get('context'); 
     // blah blah 
     } 
    } 
}); 
+0

基于这个斌http://emberjs.jsbin.com/meqef/1/edit它似乎只是在1.7.0弃用,但仍应该工作,所以我不认为这是他的问题。 – tikotzky 2014-09-02 19:49:07

+0

你是正确的 - 它已被完全删除在'1.8.0-beta.1'中,但仍应该在'1.7.0'中被弃用 – 2014-09-02 20:46:43