Looking for some really quick help,
contactForm={
that: this,
lilfield: 'I just equal this',
fields: new Array("hc_name","hc_email","hc_telephone"),
submit_button: jQuery("#hc_submit"),
init: function(){
that.lilAlert();
},
lilAlert: function(){
alert("lets pump this out");
}
}
The above is just an example, but effectively what i’m trying to achieve is that the variable that can be used to proceed calls rather than referencing the object ‘contactForm’ itself. Also that is a little safer to use than this, due to auto passing of this on events such as click etc with jQuery.
Two things.
thatis pointing to thethisthat created the contactForm, not the actual contactForm as you expect.thatis a property of the contact form so you need to access it viathis.thatorcontactForm.that, which kind of breaks the original purpose.Either:
or define the
thats inside the functions that need itIf all you want to do is avoid
thisshenanigans, an alternative is using closures (and therefore lexical, static scope instead of dynamic binding viathis)