[jQuery] How to wait until the DOM has been updated by a jquery "load" before executing subsequent JavaScript?

[jQuery] How to wait until the DOM has been updated by a jquery "load" before executing subsequent JavaScript?


Newbie question:
I'm using JQuery's load function to update a portion of my page with
new content.
This works okay but I would also like to attach event handlers to the
newly loaded content after it is loaded.
There is probably a best practice approach to doing so but I am not
aware of it.
If someone could point me in the right direction it would be much
appreciated.
The approach that I am trying is not working and I'm not sure why.
When showFavorites() is invoked, I want the content of a div in my
page to be updated with a table.
I also want to attach event handlers to the rows of the table.
Here is my code ...
function showFavorites(link){
alert('loading...');
$('div').load('/quotations/quotes2.jsp', null, attachEventHandlers
());
}
function attachEventHandlers() {
alert('number of trs ' + $('tr').size());
}
According to the jQuery documentation I expect the call to load to be
complete b4 the callback method "attachEventHandlers()" is called.
However, the behavior that I've observed is that it's alert box gets
displayed even before the one in showFavorites().
I'm confused by this behavior.