Give livequery a go - http://docs.jquery.com/Plugins/livequery
On Sun, Oct 19, 2008 at 6:08 PM, Mario Callisto <[EMAIL PROTECTED]>wrote:

>
> Hi all,
>
> I am a newbie (thank you in advance for yr patience) and stumbled upon
> an unclear behaviour (to me).
>
> I have the following sequence:
>
> 1) create an HTML object 'whatever' containing also the following 'test'
> link
> <a href="#" class="foo">test</a>
>
> 2) set it to be showed in the available div 'myDiv'
> $("#myDiv").html(whatever);
>
> 3) listen to the click on the 'test' link to trigger an action
> $('.foo').click(function(event) {
>  event.preventDefault();
>  alert ($(this).attr('class'));
> });
>
> No problems until now.
>
> But then if in the code I trigger another action that repeats steps 1)
> and 2), redisplaying the same object in the same div (the future aim of
> course would be to redisplay a slightly different object, but still
> containing the same href tag), then I get into troubles.
> Step 3 no longer works, 'test' instead of linking to the alert action
> just position me at the beginning of the page.
> So it works just the first time I load the page.
>
> I also tried to empty() the div before step 2, but no improvements.
>
> Any suggestion?
>
> Best,
>
> Mario
>
>


-- 
Ca-Phun Ung
+ http://yelotofu.com
+ css, django, hongkong, html, javascript, php

Reply via email to