如何在ember js中清除表单数据

嗨,我是非常新的ember js。 我为新员工输入了一个表格。并通过route.Data发送数据成功保存。 但问题是在表单提交后我的表单数据没有被清除。

代码如下:

app.js:

App.Router.map(function() { this.resource('saveprofile', { path: '/saveprofile/:profiledata'}); }); App.NewprofileController = Ember.ObjectController.extend({ id:'', name: '', designation: '', saveProfileAction: function () { profiledata = [{ "id": this.get("id")}, {"name": this.get("name")}, {"designation": this.get("designation")}] pdata = $.ajax({ type: "POST", dataType: "json", url: "/saveprofile?profiledata=" +profiledata, data: JSON.stringify(profiledata), dataType: "json", async: false}).done(function() { $.bootstrapGrowl("Employee added successfully", { type: 'success', align: 'center', width: '1000', allow_dismiss: false }).responseJSON }) }); console.log(pdata) } }); App.SaveProfileRoute = Ember.Route.extend({ model: function(params) { console.log(params); return Ember.$.getJSON( "/saveprofile?profiledata=" + params.profiledata); }, }) 

index.html的:

   

New Profile



{{input type="text" class="input-medium" value=id required="true"}}
{{input type="text" class="input-medium" value=name}}
{{input type="text" class="input-medium" value=designation}}

我在stackoverflow中搜索了这个,我找到了一些解决方案,但是他们使用了save和exit函数。但我没有在ember.i中使用save方法直接保存在服务器端。

我的错是什么 给我一些建议,在表单提交后清除表单数据。

你必须在控制器内执行这样的操作:

 var controller = this; //After saving the form to the server: ...then(function(){ controller.set('YourFormData', ''); }); 

您的表单数据必须是在控制器中具有绑定的属性,例如您的ID,名称和名称。