Button interactions
Component | Tests |
---|---|
js/buttonComponent.js | tests/js/buttonComponentTest.js |
Disable buttons
Disable buttons after pressing to prevent forms from being submitted multiple times.
This behaviour is enabled by default on form.submit()
buttons, all other buttons can enable this behaviour by adding the .js-submit-disable
class.
html.button({
'class': 'js-submit-disable',
'label': 'Foo'
})
Enable buttons
Enable buttons that have been disabled with the js-submit-disable
interaction by using the .js-submit-enable
interaction. This can be used in any actions which would cancel a form submission or ajax action.
html.button({
'class': 'js-submit-enable',
'label': 'Enable Foo'
})
Alternatively, re-enable all buttons that have been disabled by the .js-submit-disable
interaction by calling the buttonComponent.submitEnable()
method in your javascript.