Factorized modal dialogs javascript
This commit is contained in:
35
templates/admin/default/includes/generic-js-dialog.html
Normal file
35
templates/admin/default/includes/generic-js-dialog.html
Normal file
@@ -0,0 +1,35 @@
|
||||
{*
|
||||
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}
|
||||
|
||||
{* Always reset create dialog on close *}
|
||||
|
||||
$('#{$dialog_id}').on('hidden', function() {
|
||||
|
||||
// Hide error message
|
||||
$('#{$dialog_id}_error').remove();
|
||||
|
||||
// Clear error status
|
||||
$("#{$dialog_id} .error").removeClass('error');
|
||||
|
||||
// Empty field values
|
||||
$("#{$dialog_id} input[type=text]").val('');
|
||||
});
|
||||
Reference in New Issue
Block a user