I think the OP is adding elements to the dom, and then wondering why
the events for the new elements aren't working.

after adding elements with .html(), you need to add the events. For
example, adding an anchor:

$("#header").html('<a href="#">yo</a>').find('a').click(function()
{ alert('click'); return false; });

-j

On Mar 4, 10:53 am, Scott González <[EMAIL PROTECTED]> wrote:
> .html() doesn't have a callback because it is synchronous, so any code
> executed after the .html() call will definitely occur after the html
> is set.
>
> I'm not sure why you're having any problems, but the problem is
> probably in your code.  You'll get better responses by posting a test
> page.
>
> On Mar 4, 8:10 am, alexanmtz <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > Like a lot of methods of jQuery, why the .html() doesnt have a
> > callback?
>
> > I need that some javascript load when the dom change with .html()
> > (append and others too), and some events are attached with the new
> > elements created by this method. What happens is that sometimes they
> > are attached and other times not. I thing its due the fact that I
> > execute this code:
>
> > $('#div').html(stuffVar);
> > $.getScript('newEvents.js');
>
> > This work sometimes. I would need one way to accomplish this task like
> > this:
>
> > $("#div').html(stuffVar,function(){
> > $.getScript('newEvents.js');
>
> > });
>
> > This way, we would have sure that the html is updated and so we can
> > load the script to attach events.
>
> > Anyone has idea???
> > thanks,
>
> > Alexandre Magno
> > Web Developerhttp://blog.alexandremagno.net

Reply via email to