Fix modal opener buttons not working when added to the DOM asynchronously. #228

master
Fabio Caccamo 2022-12-14 12:38:47 +01:00
parent 112b5359cf
commit fca8e6d47b
1 changed files with 3 additions and 1 deletions

View File

@ -125,10 +125,12 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
var data = { var data = {
lookup:(lookup === true ? true : false) lookup:(lookup === true ? true : false)
}; };
// remove potential existing click event listener
var el = $(selector); var el = $(selector);
el.removeAttr('onclick'); el.removeAttr('onclick');
el.unbind('click'); el.unbind('click');
el.click(data, presentRelatedObjectModal); // listen the event on document for handling it on elements will be added to the DOM later
$(document).on('click', selector, data, presentRelatedObjectModal);
} }
// assign functions to global variables // assign functions to global variables