Skip to content

Commit

Permalink
Fix modal opener buttons not working when added to the DOM asynchrono…
Browse files Browse the repository at this point in the history
…usly. #228
  • Loading branch information
fabiocaccamo committed Dec 14, 2022
1 parent 112b535 commit fca8e6d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ if (typeof(django) !== 'undefined' && typeof(django.jQuery) !== 'undefined')
var data = {
lookup:(lookup === true ? true : false)
};
// remove potential existing click event listener
var el = $(selector);
el.removeAttr('onclick');
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
Expand Down

0 comments on commit fca8e6d

Please sign in to comment.