Please help with jquery.inview plugin with Ajax content

Please help with jquery.inview plugin with Ajax content

Jquery Inview plugin: https://github.com/zuk/jquery.inview/blob/master/jquery.inview.js

When the link "Load more" is visible, the script should trigger this link that will call the file loadmore.php and more content will appear. It works.

The problem is that dynamically loaded content also contains link "Load more" and the script doesn't trigger the new loaded link anymore.


html

<div id="cwall">content</div> <div id="more1" class="inview"><a class="morecom" id="1" href="#">Load more</a></div>

script

jQuery(function($){$(document).ready(function(){ $('.inview').bind('inview', function (event, visible, topOrBottomOrBoth) { if (visible) { $('.morecom').trigger('click'); } else { } }); $(document.body).on('click','.morecom',function() { var ID = $(this).attr("id").replace(/\|/g, '\\|'); if(ID) { $.ajax({ type: "POST", url: "/loadmore.php", data: "vid="+ ID, cache: false, success: function(html){ $("#more"+ID).remove(); $("div#cwall").append(html); } }); } else { $(".masw").html('-'); } return false; }); })});