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:
- var $popupCorreo= jQuery("<div id='mypopup'></div>");
- //loading html code into mypopup
$popupCorreo.load("mypopup_code.html");
- //setting mypopup display:none
$popupCorreo.hide();
- //appending to body (mypopup has position:absolute and max z-index)
jQuery("body").append($popupCorreo);
- //this button is in loaded code
jQuery("#button_1").bind("click", function(){
- //blah blah blah
});
- //want to change the text for button
- 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.