Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ember.js保存模型会从UI中删除元素_Javascript_Ember.js - Fatal编程技术网

Javascript ember.js保存模型会从UI中删除元素

Javascript ember.js保存模型会从UI中删除元素,javascript,ember.js,Javascript,Ember.js,我继承了一个构建在Rails API之上的Ember.js应用程序。这最初运行的是以下程序: Ember.VERSION : 1.0.0 ember.js DEBUG: Handlebars.VERSION : 1.0.0 ember.js DEBUG: jQuery.VERSION : 1.10.2 Ember : 1.7.1+pre.f095a455 ember.js DEBUG: Ember Data : 1.0.0-beta.10+canary.30d6bf849b e

我继承了一个构建在Rails API之上的Ember.js应用程序。这最初运行的是以下程序:

Ember.VERSION : 1.0.0 ember.js
DEBUG: Handlebars.VERSION : 1.0.0 ember.js
DEBUG: jQuery.VERSION : 1.10.2   
Ember      : 1.7.1+pre.f095a455 ember.js
DEBUG: Ember Data : 1.0.0-beta.10+canary.30d6bf849b ember.js
DEBUG: Handlebars : 1.3.0 ember.js
但已将其更新为以下内容:

Ember.VERSION : 1.0.0 ember.js
DEBUG: Handlebars.VERSION : 1.0.0 ember.js
DEBUG: jQuery.VERSION : 1.10.2   
Ember      : 1.7.1+pre.f095a455 ember.js
DEBUG: Ember Data : 1.0.0-beta.10+canary.30d6bf849b ember.js
DEBUG: Handlebars : 1.3.0 ember.js
使用ember rails gem

我有一个绑定到UI元素的操作来创建一个新模型,并将其插入到一行项目内的页面中。这在以前的旧应用程序中有效,但在新应用程序中无效

单击“操作”按钮时,将创建新模型,并传入行对象和初始截面数据。仅供参考,这是在节_controller.js文件中,而不是在路由中

_createSection: function(row, new_section_data){
new_section_data.row      = row;
new_section_data.width    = this.getNewSectionWidth(row);
new_section_data.position = this.getNewSectionPosition(row);

var store = this.get('store');
var new_section = store.createRecord('section', new_section_data);
new_section.save();

new_section.one('didCreate', function(){
  new_section.set('set_as_selected', true);
}.bind(this, new_section))

return new_section;
},
调用store.createRecord方法后,问题立即出现。UI布局实际上删除了应将项目放入其中的行块元素,并且不会返回或更新新插入的项目(它应该返回或更新)

我可以从Ember chrome插件中看到,原始数据存储在存储中,但不一定使用API发送到远程数据库。但主要的问题是,一旦创建了记录,用户界面就会丢失

我无法显示太多的代码,但有人知道为什么会发生这种情况吗?didCreate方法确实可以运行,但是丢失UI是一个大问题。我对余烬还相当陌生,因此仅用余烬数据之间的许多变化来更新一个遗留应用程序就有点棘手


非常感谢您提供的任何帮助。

需要查看模板。另外,这可能不是问题,但我会从“didCreate”那一个改过来。。。然后在保存。然后,您还可以提供一个错误处理程序,以便轻松查看保存是否出错。事实证明,我认为这里有一个与出错模型直接相关的不同问题。当我保存一个新的节项时,该行将从UI中消失,因为使用Ember Chrome插件,它也将从本地数据存储中消失,您可以看到它消失了。行模型与节模型有很多关系,但我仍然对保存一个会删除另一个感到困惑。我已在一个新问题中更新了该问题:并将关闭此问题。