0
我使用的是對象中的jQuery forms plugin,例如: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的其他屬性?
謝謝!
完美!謝謝 :) – dzm 2013-03-21 21:34:46