Thanks you two... How silly was i... lol


2006/9/3, John Resig <[EMAIL PROTECTED]>:
> The code:
> $(document).ready( function(){
> $("#main").load("get_calcform.php",{ idref: iditem },
>         function(txt){
>             $("#main").html(txt);
>         }
>   );
> $("#calculate").click( function(){
>    alert('hi');
>  });

The problem is that you're binding the click handler to #calculate
before it even exists in the page (since it's still being loaded by
.load(),  before). Some working code would look like this:

$("#main").load("get_calcform.php",{ idref: iditem }, function(){
    $("#calculate").click( function(){
       alert('hi');
    });
});

Since .load() already injects the HTML into #main, it's redundant to
do it again. Additionally, the click binding now waits until the new
HTML is in the page before trying to bind to it, giving you you're
desired effect. Hope that helps.

--John

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to