XF 2.3 Cancelling form submit by `e.preventDefault()` is not working

BredyAK

Member
I'm trying to create a plugin. I want to use js to cancel a form submit by following code:
JavaScript:
XF.on(form, 'ajax-submit:before', XF.proxy(this, 'beforeSubmit'));
// ...
function beforeSubmit(e) {
    console.log('beforeSubmit:', this.submitting);
    e.preventDefault();
    this.submitting = true;
}

Expected: When I click the submit button, it won't submit and console logs beforeSubmit: false.

Actually: Console shows beforeSubmit: false, but then it was submitted.

XenForo version: 2.3.7
 
Back
Top Bottom