samedi 18 avril 2015

Event registering for Ajax / Jquery get() loaded image

I am using the following code to load data into one content area of a JQuery-UI Accordion menu using get() method of Jquery. It is loading a group of images also.



$( "#accordion" ).on( "accordionactivate", function( event, ui ) {
$.get( "testb2.php")
.done(function( data ) {$('#rec1').html(data);});
});


Now the problem is the following code is not working on the loaded images.(Probably because the images were not present at the time of event registering process)



$("img").click(function(){

alert();
});


So what is the process to registering click events to Ajax loaded/jquery get() loaded images/buttons? Shall I have to call bind() method after loading all the images? in that case how?


Aucun commentaire:

Enregistrer un commentaire