diff --git a/hosting/static/hosting/js/virtual_machine_detail.js b/hosting/static/hosting/js/virtual_machine_detail.js index 303f95ca..d9345e0c 100644 --- a/hosting/static/hosting/js/virtual_machine_detail.js +++ b/hosting/static/hosting/js/virtual_machine_detail.js @@ -1,18 +1,38 @@ +$(document).ready(function () { + var create_vm_form = $('#virtual_machine_create_form'); + create_vm_form.submit(function () { + $.ajax({ + url: create_vm_form.attr('action'), + type: 'POST', + data: create_vm_form.serialize(), + success: function (data) { + if (data.status === true) { + fa_icon = $('.modal-icon > .fa'); + fa_icon.attr('class', 'fa fa-check'); + $('.modal-header > .close').attr('class', 'close'); + $('#createvm-modal-title').text(data.msg_title); + $('#createvm-modal-body').text(data.msg_body); + $('#createvm-modal').on('hidden.bs.modal', function () { + window.location = data.redirect; + }) + } + } + }); + return false; + }); -$( document ).ready(function() { + $('#confirm-cancel').on('click', '.btn-ok', function (e) { + $('#virtual_machine_cancel_form').trigger('submit'); + }); - $('#confirm-cancel').on('click', '.btn-ok', function(e) { - $('#virtual_machine_cancel_form').trigger('submit'); - }); + var hash = window.location.hash; + hash && $('ul.nav a[href="' + hash + '"]').tab('show'); - var hash = window.location.hash; - hash && $('ul.nav a[href="' + hash + '"]').tab('show'); - - $('.nav-tabs a').click(function (e) { - $(this).tab('show'); - var scrollmem = $('body').scrollTop() || $('html').scrollTop(); - window.location.hash = this.hash; - $('html,body').scrollTop(scrollmem); - }); + $('.nav-tabs a').click(function (e) { + $(this).tab('show'); + var scrollmem = $('body').scrollTop() || $('html').scrollTop(); + window.location.hash = this.hash; + $('html,body').scrollTop(scrollmem); + }); }); \ No newline at end of file