When a user clicks on an image I run a method:
$('#file-list li img').on('click', this.beeClick);
Later on, I add more images, to the list but the event fails to work. How can I apply this so that any new images also can be clicked on?
When a user clicks on an image I run a method:
$('#file-list li img').on('click', this.beeClick);
Later on, I add more images, to the list but the event fails to work. How can I apply this so that any new images also can be clicked on?
You need to use event delegation. Try this:
$('#file-list li').on('click', 'img', this.beeClick);
If you are dynamically adding an 'li' tag and an 'img' tag (not just an 'img' tag) to the already created element with an id of 'file-list' then you would need to change it to:
$('#file-list').on('click', 'img', this.beeClick);