1

I'm using a library called SweetAlert2 to display a popup. In this popup I have a basic HTML form.

function createParty() {
    $('.gui-create-party').on('click', function () {
        Swal.fire({
            title: 'EINE PARTY ERSTELLEN',
            html: '<form method="post" class="gui-jp-form gui-swal2">' +

                   //My HTML (to much to show)

                  '<input type="submit" name="gui_create_party" value="ERSTELLEN" class="gui-jp-submit">' +
                  '</form>',
            showConfirmButton: false,
            showCancelButton: false,
            cancelButtonText: 'Abbrechen'
        })
    })
}

However I have an function that will do some animation but my jQuery selector can't find the element. I'm guessing this is because the popup is getting rendered after the script is loaded. If I use the console to search for my element after the popup is displayed I find the elements, but unfortunately my animation function can't find them.

So I thought, why not adding my animation function to the HTML string like this, so it is getting executed after the popup is rendered.

'<script>avatarSelectAnim();</script>' +

Unfortunately this won't work either. Does anyone know how I could achive this? Thanks!

franky.ce
  • 21
  • 2
  • Does this answer your question? [jQuery select dynamically created html element](https://stackoverflow.com/questions/10280569/jquery-select-dynamically-created-html-element) use `$(document).on('click', '.gui-create-party' , function () {` – ikiK Feb 05 '21 at 16:47

0 Answers0