Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open modal by clicking on dynamically generated link #60

Open
kolobix opened this issue Oct 6, 2016 · 0 comments
Open

Open modal by clicking on dynamically generated link #60

kolobix opened this issue Oct 6, 2016 · 0 comments

Comments

@kolobix
Copy link

kolobix commented Oct 6, 2016

Hi,

I´m getting several elements dynamically by an Ajax-Request. Each of these elements contains a link which should open a modal when clicked. How to achieve this since dynamically generated elements are not 'recongnized' by the jquery selector?

At the moment I use this to initialize the modal:
$(".modal_trigger_login").leanModal({top : 200, overlay : 0.8, closeButton: ".modal_close" });

This works for all the elements which are not generated dynamically but not for the elements which are generated dynamically.

So I tried it with something like this:

$(document).on('click', '.modal_trigger_login', function(){
    $(this).leanModal({top : 200, overlay : 0.8, closeButton: ".modal_close" });
});

But this only works when I click the links a second time and it also seems like it 'initializes' the leanModal on each click, because on every click it adds another lean_overlay div to the page.

Thx in advance and sorry for my english

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant