I have a object in javascript and I am going to call its weeklyTargetConstraint(). Problem is that it will call a method displayWeeklyTargetPrompt(), but this will not carry the object reference in the method call.
Why is the console printing out the Window object? And how am a suppose to do this properly?
function main() {
c = new Constraints(5,6);
c.weeklyTargetConstraint();
}
function Constraints(weekNum, dayID) {
//setup
}
Constraints.prototype = {
weeklyTargetConstraint: function () {
var state = $("#hfWeeklyFillOverride", weekNumber).val();
this.constraintQty(this.fillTarget, state, this.displayWeeklyTargetPrompt);
///this will call displayWeeklyTargetPrompt()...
},
displayWeeklyTargetPrompt: function () {
console.log(this); // this is the Window Object
console.log(this.weekNumber); // its a input with id = weekNumber
loadWeeklyFillTargetMsg(this.weekNumber);
$('#weeklyTargetConfirm').dialog('open');
},
// other stuff here
}