I have this simplified jquery :
$(document).ready(function(){
$( ".product_imgfiles a" ).click(function(event) {
event.preventDefault();
alert ("you just click it");
});
//some codes cut here
if (rejected == "" ) {
$.getJSON("controller/ctrl.dropzonejs-imgfiles.php?dir='.$product_token.'",function(json){
$.each( json, function( key, val ) {
if (!$("#product_imgfiles_container img[src='"+val+"']").length){
$( "#product_imgfiles_container" ).append( "<div class='col-xs-4 col-md-2'><div class='thumbnail product_imgfiles'><img src='+val+'><a href=''>delete</a></div></div>" );
}
});
});
}
});
the problem is... $( ".product_imgfiles a" ).click(function(event)
only works on elements which loaded when document is ready. not new element which just added by conditional json under IF statement.
how to make it works for both situation? thank you