如何摆脱此错误并让我的行动正常工作?
我有一个用于创建新图表的页面,但无法使我的transitionToRoute正常工作。这是取消操作的情况。
我的环境:
DEBUG: -------------------------------
DEBUG: Ember : 1.4.1+pre.af87bd20
DEBUG: Ember Data : 1.0.0-beta.7.f87cba88
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery : 1.11.0
DEBUG: -------------------------------
我的数据通过Rails 4 api提供。
我的错误(在Chrome控制台中):
Rendering graphs.index with default view <Ember._MetamorphView:ember421> Object {fullName: "view:graphs.index"} ember.js?body=1:3464
Uncaught TypeError: Cannot read property 'unchain' of undefined ember.js?body=1:4123
完整错误(在控制台中展开未捕获的类型错误):
Uncaught TypeError: Cannot read property 'unchain' of undefined ember.js?body=1:4123
ChainNodePrototype.unchain ember.js?body=1:4123
ChainNodePrototype.remove ember.js?body=1:4095
Ember.unwatchPath ember.js?body=1:4314
Ember.unwatch ember.js?body=1:4383
Ember.removeObserver ember.js?body=1:5652
(anonymous function) ember.js?body=1:24300
sendEvent ember.js?body=1:2540
Ember.Evented.Ember.Mixin.create.trigger ember.js?body=1:18025
Ember.CoreView.Ember.Object.extend.trigger ember.js?body=1:22211
superWrapper ember.js?body=1:1242
ViewCollection.trigger ember.js?body=1:22276
Ember.View.Ember.CoreView.extend._notifyWillDestroyElement ember.js?body=1:23792
Ember.merge.destroyElement ember.js?body=1:24780
Ember.View.Ember.CoreView.extend.destroyElement ember.js?body=1:23767
superWrapper ember.js?body=1:1242
Ember.CoreView.Ember.Object.extend.destroy ember.js?body=1:22245
superWrapper ember.js?body=1:1242
Ember.View.Ember.CoreView.extend.destroy ember.js?body=1:24101
superWrapper ember.js?body=1:1242
(anonymous function) ember.js?body=1:25235
sendEvent ember.js?body=1:2540
notifyBeforeObservers ember.js?body=1:2912
propertyWillChange ember.js?body=1:2738
set ember.js?body=1:2994
Ember.trySet ember.js?body=1:3063
(anonymous function) ember.js?body=1:7236
tryable ember.js?body=1:2434
Ember.tryFinally ember.js?body=1:1424
suspendListener ember.js?body=1:2437
Ember._suspendObserver ember.js?body=1:5681
Binding._sync ember.js?body=1:7235
DeferredActionQueues.flush ember.js?body=1:5896
Backburner.end ember.js?body=1:5987
Backburner.run ember.js?body=1:6026
Ember.run ember.js?body=1:6429
hash.success ember-data.js?body=1:1526
fire jquery.js?body=1:3100
self.fireWith jquery.js?body=1:3212
done jquery.js?body=1:9311
callback jquery.js?body=1:9721
在恩伯:
控制器:
App.GraphsNewController = Ember.ObjectController.extend({
headerTitle: 'Create',
buttonTitle: 'Create',
actions: {
save: function(){
this.content.save().then(function(){
this.transitionToRoute('graphs.show',this.content);
});
},
cancel: function(){
this.content.deleteRecord();
this.transitionToRoute('graphs.index');
}
}
});
路线:
App.GraphsNewRoute = Ember.Route.extend({
model: function(){
return this.store.createRecord('graph');
}
});
模板:
<h1>This is new</h1>
<div class='large-12 columns'>
{{ partial 'graphs/form' }}
</div>
部分:
<form>
<fieldset>
<legend>Graph</legend>
<div class="row">
<div class="large-12 columns">
<label {{bind-attr for="titleField.elementId"}}>Title</label>
{{view Ember.TextField valueBinding='title' name='title' viewName='titleField' placeholder="Graph title"}}
</div>
</div>
<div class="row">
<div class="large-6 columns">
<label {{bind-attr for='dataField.elementId'}}>Data</label>
{{view Ember.TextField valueBinding='data' name='data' viewName='dataField' placeholder="Graph data"}}
</div>
<div class="large-6 columns">
<label {{bind-attr for='VisualizationField.elementId'}}>Visualization</label>
{{view Ember.TextField valueBinding='visualization' name='visualization' viewName='VisualizationField' placeholder="Graph visualization"}}
</div>
</div>
</fieldset>
</form>
<div class="button-bar">
<ul class="button-group">
<li><a class="small button success" {{action 'save'}} >{{buttonTitle}}</a></li>
<li><a class='small button alert' {{action 'cancel'}} >Cancel</a></li>
</ul>
</div>