problems manipulating loaded DOM

problems manipulating loaded DOM

Hello all.

I have some problems when I try to manipulate a piece of HTML loaded by jQuery.load() function.

Here is my code:

  1.     var $popupCorreo= jQuery("<div id='mypopup'></div>");
  2.     //loading html code into mypopup
        $popupCorreo.load("mypopup_code.html");
  3.     //setting mypopup display:none
        $popupCorreo.hide();
       



  4.     //appending to body (mypopup has position:absolute and max z-index)
        jQuery("body").append($popupCorreo);
       



  5.     //this button is in loaded code
        jQuery("#button_1").bind("click", function(){
  6.             //blah blah blah
        });


  7.       //want to change the text for button

  8.     jQuery("#button_1").text("new text for button");

Ok, I append the loaded code and then, bind the event and change some text in a loaded button, but it does not work.

If I change my code, live instead of bind, events work correctly. I tried to debug with firebug on Firefox 3.5 and all works fine only if I set a breakpoint between load and bind lines.
It seems to be any type of delay while loading. Or am I wrong?

How can I manage with that delay?

I was trying to find any information at this forum, but I did not manage to find anything. if I missed any post with relevant information, please, tell me.


Thanks all in advance.

Regards.