Initial commit
This commit is contained in:
60
templates/backOffice/default/includes/generic-js-dialog.html
Normal file
60
templates/backOffice/default/includes/generic-js-dialog.html
Normal file
@@ -0,0 +1,60 @@
|
||||
{*
|
||||
Javascript code to manage create dialog. Insert it in your template, in the javascript
|
||||
initialisation:
|
||||
|
||||
$(function() {
|
||||
<insert me here>
|
||||
}
|
||||
|
||||
Parameters:
|
||||
$dialog_id = the dialog ID
|
||||
$form_name = the form name
|
||||
|
||||
*}
|
||||
|
||||
{* re-display the form creation dialog if it contains errors *}
|
||||
|
||||
{form name="{$form_name}"}
|
||||
{if $form_error}
|
||||
$('#{$dialog_id}').modal();
|
||||
{/if}
|
||||
{/form}
|
||||
|
||||
|
||||
{*
|
||||
Prevent multiple form submissions
|
||||
you can deactivate this behavior in setting data-submitting='0' on the form tag
|
||||
*}
|
||||
$('#{$dialog_id} form').on("submit", function(e) {
|
||||
var submitting = $(this).data('submitting');
|
||||
if (submitting == '1') {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if (submitting != '0') {
|
||||
$(this).data('submitting', '1');
|
||||
}
|
||||
});
|
||||
|
||||
{* Always reset create dialog on close *}
|
||||
|
||||
$('#{$dialog_id}').on('hidden.bs.modal', function() {
|
||||
|
||||
var submitting = false;
|
||||
|
||||
// Hide error message
|
||||
$('#{$dialog_id}_error').remove();
|
||||
|
||||
// Clear error status
|
||||
$("#{$dialog_id} .error").removeClass('error');
|
||||
|
||||
$('#{$dialog_id} .form-group').removeClass('has-error')
|
||||
|
||||
// Empty field values
|
||||
$("#{$dialog_id} input[type=text], #{$dialog_id} select").val('');
|
||||
|
||||
// Uncheck boxes
|
||||
$("#{$dialog_id} input[type=checkbox]").removeAttr('checked');
|
||||
|
||||
{$additionnal_js_code|default:''}
|
||||
});
|
||||
Reference in New Issue
Block a user