Only create the modal if it does not exist.

This commit is contained in:
Víðir Valberg Guðmundsson 2017-04-15 19:43:30 +02:00
parent 10ff284997
commit cad2b468e4

View file

@ -80,12 +80,18 @@
function openModal(e) {
e.preventDefault();
event_instance_id = e.target.dataset['eventinstanceId'];
modal = modals[event_instance_id];
if(modal == undefined) {
template = document.getElementById('event-template');
modal = template.cloneNode(true);
body = document.getElementsByTagName('body')[0];
body.appendChild(modal);
modal.setAttribute('id', 'event-modal-' + event_instance_id)
modals[event_instance_id] = modal;
}
$('#event-modal-' + event_instance_id).modal();
webSocketBridge.send({action: 'get_event_instance', event_instance_id: event_instance_id})
}