简体   繁体   中英

Jquery plugin confirmOn not work with ajax loaded DOM

Please help me. I don`t know how to work plugin with DOM element loaded after $(document).ready This is sample

 $('.menu_confirm').confirmOn('click', function (e, confirmed) {
        if (confirmed) { // Clicked yes
alert (1);
}else { // Clicked no
 alert (2); 
        }
    });

Thank you!

Try this:

 $(body).confirmOn('click', '.menu_confirm',function (e, confirmed) {
    if (confirmed) { // Clicked yes
      alert (1);
    }else { // Clicked no
      alert (2); 
    }
 });

Better you use a subcontainer for reference (better performance):

 $('.heres_ajaxcontent').confirmOn('click', '.menu_confirm',function (e, confirmed) {
    if (confirmed) { // Clicked yes
      alert (1);
    }else { // Clicked no
      alert (2); 
    }
 });

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