オブジェクト内でjQueryフォームプラグインを使用しています。例:
var myObject = {
el : $('#form'),
init : function() {
var options = {
beforeSubmit: this.submitRequest,
success: this.submitResponse,
error: function(xhr, reply, error) {
}
};
this.el.ajaxForm(options);
},
submitRequest : function(formData, jqForm, options) {
//this no longer contains the el attribute or access to any other myObject properties
console.log(this);
},
submitResponse : function() {
}
};
これは、beforeSubmitが呼び出している場合に見られますがthis.submitRequest
、その関数内では、myObjectのコンテキストを取得できません。コンテキストを渡す方法やmyObjectの他のプロパティにアクセスする方法はありますか?
ありがとうございました!