I’m an jQuery noob and I’m wondering how fix this issue:
- I have an external .js script, let’s take reflection.js as example.
- Reflection.js creates canvas reflection for every class=”reflect” image.
- I’m appending a few images trough different JS script that starts when (‘document’).ready.
- Of course reflection.js doesn’t work for images created by the script above.
How to avoid that?
I guess I’ll need callback (?). Unfortunately I’m not getting idea of callbacks idea even after reading documentation.
[edit]
<script src="js/reflection.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery().ready(function() {
jQuery('#thumbs li').each(function(){
jQuery('.'+id+' a').append('<img src="' + imgURL + '" class="reflect" /></a>');
});
});
</script>
Image loading events do not bubble. You cannot hook into those.
Since your images have the class “reflect” it means you have some control over the source. So I recommend your reflection code publishes an API for you to call.
If you do not want to do this then you can poll the document for new images.