javascript - 'this.variable' doesn't change? -


I will create a group of new objects from the function below, then from within a loop, I loop through each one and Call methods toggleValid () and toggleErrMsg () in ToggleErrMsg (), it assumes that the value of object.errMsgStatus is correct, but it is not. Why?

  InputField (field, cssTarget, value, error message, verifier) ​​function {var self = this; This.field = Area, this.cssTarget = cssTarget, this.value = value, this.valid = false, this.errMsg = errMsg, this.errMsgStatus = false, this.validator = validator, this.toggleErrMsg = function () { If (self.valid === false & self-Erstestus === false) {self.errMsgStatus = true; RenderValidationError (auto, incorrect); } And {self.errMsgStatus = false; RenderValidationError (auto, true); }} This.toggleValid = function () {self.validator (); If (! Self.valid) {self.cssTarget () AddClass ("inputInvalid"); } Else {self.cssTarget (). RemoveClass ("inputInvalid"); }}}}  

Perhaps you have to do with the way to start the input field. As no code has been given, you are probably

  var inputField = InputField ();  

While this should be

  var inputField = new InputField ();  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -