尋找一些真正快速幫助,Javascript對象通過自身
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");
}
}
上述只是一個例子,但是有效地我想要實現的是可以使用的變量進行呼叫,而比引用對象'contactForm'本身。此外,這比使用這個更安全一些,因爲這會自動傳遞給jQuery等點擊等事件。
您是否在尋找http://api.jquery.com/jQuery.extend/關閉(因此詞法,靜態的範圍,而不是通過動態綁定
this
)? – 2011-12-15 11:14:24