// wait till the fabrik core JS is loaded ...
requirejs(['fab/fabrik'], function () {
// as soon as the form is loaded, add a wrapper around the submit button
Fabrik.addEvent('fabrik.form.loaded', function(form) {
jQuery('.btn.save').wrap('<div class="mySubmitWrapper" style="display: inline-block"></div>');
}
// add an event handler to run on the togglesubmit event
Fabrik.addEvent('fabrik.form.togglesubmit', function(form, enable) {
// check the 'enable' arg
if (!enable) {
// enable is false, so being disabled, so add tooltip to the wrapper
jQuery('.mySubmitWrapper').data('toggle', 'tooltip');
jQuery('.mySubmitWrapper').attr('title', 'Your form cannot be saved until all inputs have been validated');
jQuery('.mySubmitWrapper').tooltip();
}
else {
// enable is true, so destroy tooltip
jQuery('.mySubmitWrapper').tooltip('destroy');
}
});
});