简体   繁体   中英

Modalbox - .click event not working after ajax call

I have integrated a modal box from this page: http://leanmodal.finelysliced.com.au . When I am working with elements on the page, the modal box works fine. However, when I receive data from a AJAX call, the click event doesn't work.

The problem seems to be that .click only works for elements that are already on the page. The problem is that .click only works for elements already on the page - and by using "on", it should work. I have tried editing the js-file but without succes.

Link to js: http://leanmodal.finelysliced.com.au/js/jquery.leanModal.min.js

How should i edit the js-file? Thanks in advance.

Ensure that the inserted elements from the ajax call have the correct attributes (rel="leanModal") that the modal script will look for.

After inserting that ajax data into the page, you should then assign the modal code to the new elements by;

$('a[rel*=leanModal]').leanModal({ top : 200, closeButton: ".modal_close" });   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM