我想在闭包函数中调用onCallback
,有更好的方法吗?感谢您的意见和建议。
$.A.commentForm = function() {
var hasWritten = false;
var that = this;
return {
init: function () {
$('#commentWriteForm').submit(this.onSubmit);
},
onSubmit: function (e) {
var $form = $('#commentWriteForm');
e.preventDefault()
$.post($form.attr('action'), $form.serialize(), $.A.commentForm.onCallback, 'json');
// ^^^^^ how to refactor this?
},
onCallback: function (data) {
/* ... */
}
};
}();
$.A.commentForm.init();