0

I initially load into my page a table via "load".

$("#adresscontainer").load("/shop_stammdaten_get_adressliste.php", function() {

Within this function which is triggered by a click on a button which open a dialog form. Initially this works fine.

 $(".create-user").on("click", function(e) {

This form will create a new entry in the table. I add this entry via APPEND to the table. Button the new entry has also a button to edit the line.

$( "#inneradressbox" ).append("<div id='inneradressbox'><button CLASS='create-user' id='TestID'>Bearbeiten</button></div>");

But if I click now on the new added button it this trigger not JQUERY not anymore.

I guess the reason is that the new button is not added to the EventListener. But I have no idea how I can add this now to this. I heared about BIND and ON but where in my append line should I do this? O rmust I change the structure of my code totally?

Hopefully somebody can help me?

Thanks Mark

couganet
  • 13
  • 3
  • Attach the event listener to a parent element: `$(document).on('click', '.create-user', function(e) {` – Andy Aug 08 '21 at 08:20
  • 1
    @Andy: Thanks for this. It's exactly what I looking for. I just tried it on the wrong place. Thanks. You saved my Sunday. – couganet Aug 08 '21 at 13:50
  • @couganet See [event delegation](https://learn.jquery.com/events/event-delegation/) – Andy Aug 08 '21 at 13:54

0 Answers0