Commit 210e6c32 by Kálmán Viktor

dashboard: reworked modal creation with ajax

parent 23688646
......@@ -4,26 +4,7 @@ $(function () {
type: 'GET',
url: '/dashboard/vm/create/',
success: function(data) {
// TODO this is still ugly
var html = '<div class="modal fade" id="vm-create-modal" tabindex="-1" role="dialog">' +
'<div class="modal-dialog">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
'<h4 class="modal-title">Create VM</h4>' +
'</div>' +
'<div class="modal-body"> ' +
data +
'</div>' +
/*'<div class="modal-footer">' +
'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>' +
'<button type="button" class="btn btn-primary">Save changes</button>' +
'</div>' + */
'</div><!-- /.modal-content -->' +
'</div><!-- /.modal-dialog -->' +
$('#vm-create-modal').on('', function() {
<div class="modal fade" id="vm-create-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">{{ box_title }}</h4>
<div class="modal-body">
{% include template %}
<!--<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
......@@ -94,13 +94,12 @@ class VmCreate(TemplateView):
def get_template_names(self):
if self.request.is_ajax():
return ['dashboard/vm-create.html']
return ['dashboard/modal-wrapper.html']
return ['dashboard/ajax-wrapper.html']
return ['dashboard/nojs-wrapper.html']
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
if not request.is_ajax():
'template': 'dashboard/vm-create.html',
'box_title': 'Create a VM'
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