Commit 7916199f by Kálmán Viktor

dashboard: add comments to vm-ops js

parent 00b87bac
...@@ -41,16 +41,25 @@ $(function() { ...@@ -41,16 +41,25 @@ $(function() {
type: 'POST', type: 'POST',
data: $(this).closest('form').serialize(), data: $(this).closest('form').serialize(),
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
/* hide the modal we just submitted */
$('#confirmation-modal').modal("hide"); $('#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) { if(data.success) {
$('a[href="#activity"]').trigger("click"); $('a[href="#activity"]').trigger("click");
/* if there are messages display them */
if(data.messages && data.messages.length > 0) { if(data.messages && data.messages.length > 0) {
addMessage(data.messages.join("<br />"), "danger"); addMessage(data.messages.join("<br />"), "danger");
} }
} }
else { 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() { $('#confirmation-modal').on('hidden.bs.modal', function() {
$('body').append(data); $('body').append(data);
$('#confirmation-modal').modal('show'); $('#confirmation-modal').modal('show');
...@@ -61,7 +70,7 @@ $(function() { ...@@ -61,7 +70,7 @@ $(function() {
} }
}, },
error: function(xhr, textStatus, error) { error: function(xhr, textStatus, error) {
var r = $('#create-modal'); r.next('div').remove(); r.remove(); $('#confirmation-modal').modal("hide");
if (xhr.status == 500) { if (xhr.status == 500) {
addMessage("500 Internal Server Error", "danger"); addMessage("500 Internal Server Error", "danger");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment