From f9fd2bb54e2492d4654f5a6023023234b51a62fe Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 11 Feb 2015 21:32:13 +0100 Subject: contacts can now be added without reloading the page --- include/contacts-overview.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'include/contacts-overview.php') diff --git a/include/contacts-overview.php b/include/contacts-overview.php index 3fb1eb1..8548e3e 100644 --- a/include/contacts-overview.php +++ b/include/contacts-overview.php @@ -72,7 +72,7 @@
Create new
+ data-ajaxify-options='{"success":"newContactSuccess","error":"newContactError","beforeSubmit":"newContactBeforeSubmit"}'>
@@ -132,24 +132,16 @@ // Callback for when the form is successfully submitted function newContactSuccess(data) { - if (data.success == true) { - $('#newContact .ajaxify-response') - .addClass('alert-success') - .show() - .find('.ajaxify-response-text') - .html(data.message); - - $('#newContact input, #newContact button').prop('disabled', false); - $('#newContact').data('bootstrapValidator').resetForm(); - } else { - $('#newContact .ajaxify-response') - .addClass('alert-danger') - .show() - .find('.ajaxify-response-text') - .html(data.message); + $('#newContact .ajaxify-response') + .addClass(data.success ? 'alert-success' : 'alert-danger') + .show() + .find('.ajaxify-response-text') + .html(data.message); - $('#newContact input, #newContact button').prop('disabled', false); - $('#newContact').data('bootstrapValidator').resetForm(); + $('#newContact input, #newContact button').prop('disabled', false); + $('#newContact').data('bootstrapValidator').resetForm(); + if (data.success) { + $('#newContact input').val(''); } } -- cgit v1.2.3