From 7916199ff9e7c3a963c285772fc5a7d73240c705 Mon Sep 17 00:00:00 2001 From: Kálmán Viktor <kviktor@cloud.bme.hu> Date: Wed, 25 Jun 2014 18:18:13 +0200 Subject: [PATCH] dashboard: add comments to vm-ops js --- circle/dashboard/static/dashboard/vm-common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/circle/dashboard/static/dashboard/vm-common.js b/circle/dashboard/static/dashboard/vm-common.js index 677be8d..05bfbbf 100644 --- a/circle/dashboard/static/dashboard/vm-common.js +++ b/circle/dashboard/static/dashboard/vm-common.js @@ -41,16 +41,25 @@ $(function() { type: 'POST', data: $(this).closest('form').serialize(), success: function(data, textStatus, xhr) { + /* hide the modal we just submitted */ $('#confirmation-modal').modal("hide"); + /* if it was successful trigger a click event on activity, this will + * - go to that tab + * - starts refreshing the activity + */ if(data.success) { $('a[href="#activity"]').trigger("click"); + /* if there are messages display them */ if(data.messages && data.messages.length > 0) { addMessage(data.messages.join("<br />"), "danger"); } } else { + /* if the post was not successful wait for the modal to disappear + * then append the new modal + */ $('#confirmation-modal').on('hidden.bs.modal', function() { $('body').append(data); $('#confirmation-modal').modal('show'); @@ -61,7 +70,7 @@ $(function() { } }, error: function(xhr, textStatus, error) { - var r = $('#create-modal'); r.next('div').remove(); r.remove(); + $('#confirmation-modal').modal("hide"); if (xhr.status == 500) { addMessage("500 Internal Server Error", "danger"); -- libgit2 0.26.0