You're calling the function "attachEventHandlers" instead of passing a
reference to the function.  Take the () off.


On Wed, Sep 16, 2009 at 9:55 AM, alexryan <alexander.j.r...@gmail.com> wrote:
>
> 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.
>



-- 
Turtle, turtle, on the ground,
Pink and shiny, turn around.

Reply via email to