Fixed #53 - Cancel button does not work

pull/57/head
Fabio Caccamo 2019-02-06 17:01:17 +01:00
parent a48d2175ba
commit efb38d5825
1 changed files with 3 additions and 9 deletions

View File

@ -1,24 +1,18 @@
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
{
if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined') {
(function($) {
'use strict';
$(document).ready(function() {
$('.cancel-link').click(function(e) {
e.preventDefault();
var parentWindow = window.parent;
if (parentWindow && typeof(parentWindow.dismissRelatedObjectModal) === 'function') {
if (parentWindow && typeof(parentWindow.dismissRelatedObjectModal) === 'function' && parentWindow !== window) {
parentWindow.dismissRelatedObjectModal();
} else {
// fallback to default behavior
history.back();
window.history.back();
}
return false;
});
});
})(django.jQuery);
}