Я пытаюсь передать функцию (с параметром) другой функции внутри объекта json.Оно всегда не определено, и я не могу найти причину.
Первый запуск функции packtNs.graduateForm.loadEvent
.Затем отправка функции packtNs.common.populateWithTodaysDate("packt_supervisor", "packt_postgraduatestartdate")
функции packtNs.common.wireOnChangeEvents
.
Вот мой код:
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");
}
packtNs.common.wireOnChangeEvents =
function(eventAttributeTuples){
debugger;
for (var i in eventAttributeTuples) {
console.log(eventAttributeTuples[i].attribute);
////attribute is OK
console.log(eventAttributeTuples[i].function);
////function is always undefined. eventAttributeTuples[0] object doesnt have function - tried different names
}
}
packtNs.graduateForm = packtNs.graduateForm || {};
packtNs.graduateForm.loadEvent = function(){
packtNs.common.wireOnChangeEvents([
{
attribute: "packt_supervisor",
function:packtNs.common.populateWithTodaysDate("packt_supervisor", "packt_postgraduatestartdate")
}
]);
debugger;
}