I have a table of rows that are dynamically managed via listjs. I have made these rows clickable to open a Bootstrap Modal based on a data attribute (data-modal). This all works fine except for when a link appears in the columns of the rows. Both the anchor is firing and the modal is opening.
To prevent this, I used the following code, which worked on initially loaded elements:
$("[data-modal]").on("click", "a:not(.open-disabled)", function(e) {//open modal code}
But as expected, this doesn't bind to dynamically injected rows or divs.
So I changed my code to try binding to $(document) instead, but I can't get the :not selector to chain properly -- the selectors aren't being properly identified and the modal does not open.
Here is what I changed my code to:
$(document).on("click", "[data-modal], a:not(.open-disabled)", function(e) {}
Questions: A. How do I chain selectors in the above to prevent the modal from opening if there is an anchor child element that is being clicked.
B. Is there a better method of preventing the modal from opening?