我有以下代码。当我收到ajax查询的响应时,我正在尝试将事件发送到其他类型。我正在使用enyo JsonpSource。
new enyo.JsonpSource({ name: "json" });
//new enyo.AjaxSource({ name: "json" });
enyo.kind({
name: "AccountSetup",
//kind: "enyo.Model",
source: "json",
options: { parse: true },
getUrl: function () {
return "https://223.30.248.51:1926/HotelInfoServlet?Q=ACTIVATE&UA=1300029800&MODE=JSON";
},
events:
{ onMyEvent: ''
},
gotData : function(){
//this.inherited(arguments);
console.log("In gotData \n");
// console.log(tmp);
console.log(accountSetup);
this.doMyEvent({answer:accountSetup});
},
//this.doMyEvent({answer:accountSetup});
success : function(){
alert("Here!\n");
},
});
var accountSetup = new AccountSetup();
accountSetup.fetch();
/* process callback data*/
function callback (data)
{
if (data.type == "accountsetup") {
console.log(data);
console.log(this);
var acsetup = new AccountSetup();
accountSetup= data;
//acsetup = data;
console.log(acsetup);
//acsetup.doMyEvent({answer : data});
//accountSetup.gotData();
acsetup.gotData();
}
};
在这,我得到错误
Uncaught TypeError: accountSetup.fetch is not a function
。
如果我删除了enyo.model
的评论,我会收到错误消息
Uncaught TypeError: this.doMyEvent is not a function
。
问题出在哪里?
答案 0 :(得分:1)
好的,有几件事。
我认为您可能需要更仔细地了解enyo.Model的工作原理。