I have this function:
$(document).on('scroll', function(e)
{
if (processing)
return false;
if ($(window).scrollTop() >= ($(document).height() - $(window).height())*0.9)
{
processing = true;
var resource = $('#lazyLoad').attr('href');
$.get(resource, '', function(data)
{
$('#lazyLoad').remove();
$('#content').append(data);
step++;
processing = false;
});
}
});
I add some html code to my page every time this function is called. But other Javascript functions are not triggered when I click on a newly added html button. So I guess the DOM-element was not porper updated. But how do I proper update the DOM-element?
My Handler looks like this:
$('.article_action.un_read').on('click', function(event)
{
event.preventDefault();
var resource = $(this).attr('href');
var elElemente = $(this);
$.get(resource, '', function(data)
{
var obj = $.parseJSON(data);
if(obj.status == 1)
elElemente.html('📕');
else
elElemente.html('📖');
});
});
So it also uses the on
function.