href javascript function call
<p>I am trying to call a function on href but its showing undefined function but the function itself is working when I call it inside album loop. Is there some other way of calling the function after appending the href? I tried using jquery onclick with the id of anchor but that doesn't work either and got no error. Any idea how I should be calling?</p>

<pre><code>function getPhotosByAlbumID(albumID){
    FB.api('/'+ albumID + '/photos',{ limit: 5000, fields: 'source' }, function(photos) {
        $(photos.data).each(function(index, value){
            console.log(value.source);
        });
    });
}

FB.api('/me/albums',{ limit: 5000, fields: 'id,name,count,cover_photo,link' }, function(me_album) {
    $(me_album.data).each(function(index, value){                           
        FB.api('/'+value.id+'/picture',{ limit: 5000 }, function(picture) {                     
            $('#facebook-cover').append('&lt;li id="'+value.id+'"&gt;&lt;a href="javascript:getPhotosByAlbumID('+value.id+');" id="album"&gt;&lt;img src="'+picture.data.url+'" /&gt;&lt;/a&gt;&lt;/li&gt;'); 
        });
    });
}); 
</code></pre>

<p>Error: Uncaught ReferenceError: getPhotosByAlbumID is not defined </p>

<p>All appended like so.. </p>

<pre><code>&lt;ul id="facebook-cover"&gt;
&lt;li id="4758611198834"&gt;&lt;a href="javascript:getPhotosByAlbumID(4758611198834);" id="album"&gt;&lt;img src="image-link"&gt;&lt;/a&gt;&lt;/li&gt;   
&lt;/ul&gt;
</code></pre>
