我正在使用ember.js完成我的第一步,并且遇到了一些问题。
提交表单后,将使用jQuery发送POST(工作正常)。之后,成功函数应将“val1”更改为“newVal”。不幸的是,我不知道如何实现这一点。
HTML:
<form {{action "submitAction" on="submit"}}>...</form>
JS:
App.IndexController = Ember.Controller.extend({
prop1: "val1",
prop2: "val2",
submitAction: function () {
// here, this.set("prop1","newVal") works fine.
$.ajax({
//(...)
type: "POST",
success: function () {
// but how can I set it here?
},
//(...)
}
});
答案 0 :(得分:1)
试试这个
App.IndexController = Ember.Controller.extend({
prop1: "val1",
prop2: "val2",
submitAction: function () {
// here, this.set("prop1","newVal") works fine.
var $submit = $(this);
$.ajax({
//(...)
type: "POST",
success: function () {
// but how can I set it here?
$submit.set("prop1","newVal");
},
//(...)
}
});