这是一个名称间隔的对象,不是JSON,但是要获得一些东西,必须返回一些东西。我把你的“功能”改名为“神话”,因为它错了。
var packtNs = packtNs || {};
packtNs.common = packtNs.common || {};
/**
* A method that populates the post graduate start date
* when the supervisor lookup is populated.
* @returns {Void}
*/
packtNs.common.populateWithTodaysDate = function(attributeToMonitor, dateAttributeToChange) {
console.log("Populatewithtodaysdate function triggered");
return {
arg1: attributeToMonitor,
arg2: dateAttributeToChange
};
}
packtNs.common
.wireOnChangeEvents = function(eventAttributeTuples) {
//debugger;
console.log("tup:", eventAttributeTuples);
for (var i in eventAttributeTuples) {
console.log(eventAttributeTuples[i].attribute);
////attribute is OK
console.log(eventAttributeTuples[i].mything);
////function is always undefined. eventAttributeTuples[0] object doesnt have function - tried different names
}
return eventAttributeTuples;
}
packtNs.graduateForm = packtNs.graduateForm || {};
packtNs.graduateForm.loadEvent = function() {
return packtNs.common.wireOnChangeEvents([{
attribute: "packt_supervisor",
mything: packtNs.common.populateWithTodaysDate("packt_supervisor", "packt_postgraduatestartdate")
}]);
// debugger;
}
var myresult = packtNs.graduateForm.loadEvent();
console.log("myresult:",myresult);