When creating dynamic divs on a modal form with a close button to destroy them, everything was working fine. However, when I added a button to add new divs/forms items, the close button callback was not being triggered and instead closed the modal without destroying the div itself. The issue seems to be related to the callback function not being called when the rows are created using addNewRow. Below is the code snippet:
console.log("hello");
var myModal = $('#exampleModal');
var myForm = $('#exampleModal #myForm');
// rest of JavaScript code goes here...
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Mara test</title>
</head>
<body>
<!-- Button trigger modal -->
// rest of HTML code goes here...
</body>
</html>