I have following code.I am trying to send event to other kind when I get response of ajax query.I am using 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();
}
};
In this,I get error as
Uncaught TypeError: accountSetup.fetch is not a function
.
If I removed comment of enyo.model
, I get error as
Uncaught TypeError: this.doMyEvent is not a function
.
Where is the problem occurring?