Design issue "DisableOnSubmit" should check if element should be disabled before re-enabling it

Chris D

XenForo developer
Staff member
I have a Disabler activated for a submit button so that a user confirmation is required before submitting a form (confirming agreement of a license agreement / terms and conditions).

When the "I agree..." checkbox is clicked, the submit button is activated. When the submit button is clicked, as expected, the submit button is disabled for X seconds. If before X seconds is up, you then uncheck the I agree checkbox (hence the submit button should be disabled), when the timer runs out it re-enables the submit button, despite the Disabler being in such a state that should keep the button disabled:

upload_2014-9-6_11-10-59.webp
 
I'm going to say that this is mostly out of the scope of the default code. There will always be a challenge when multiple behaviors compete over a single attribute. I would imagine there are other situations like this.

That said, you can listen to EnableSubmitButtons on the containing form and trigger XFRecalculate which should handle it.
 
That definitely sounded worth a try, but it didn't work.

Code:
$form.on('EnableSubmitButtons', function(e)
{
    console.log('EnableSubmitButtons!');
    $form.trigger('XFRecalculate');
});

And I also modified XFRecalculate in xenforo.js thus for testing:
Code:
$form.bind('XFRecalculate', function() { console.log('XFRecalculate!'); setStatus(null, true); });

And everything seems to fire ok:
upload_2014-9-8_13-55-57.webp

But still it doesn't re-disable the buttons based on the Disabler state.

I haven't gone further than that, mostly because I've worked around the issue by making the Download button an OverlayCloser and not caching the overlay, but thought it worth mentioning.
 
Top Bottom