[jQuery] ready() to bind post-ajax events

[jQuery] ready() to bind post-ajax events


I haven't seen much mention of this on the web, and only recently
discovered it works.... not sure if this is somehow bad practice or
just a lesser known trick, but lately I've been chaining .ready() at
the end of .html() when I want to bind events to new ajax data... I
presume it's much more efficient than live(), and avoids racing
issues. EG:
$.ajax({
     type: 'POST',
     url: 'myPage.html',
     success: function(c){
     $(".response").html(c).ready(function() {
             bindNewEvent(".response a");
     });
});
function bindNewEvent(o) {
$(o).click(funciton() { ...etc... });
};
There's infinite docs about using .ready() to process the document,
but not returning HTML. Passing the above along should anyone find it
useful or have insight onto why it's seemingly not mentioned elsewhere.