Okay - I figured it out, so I thought I'd post here as a reference for
anyone else:

Basically, in the "Callback" at the end of the .load function is where
the new click function needs to be, with the addition of find(). So
add $("#new_content").find("a").click(function(){...}) inside the
Callback.

Not elegant perhaps, but at least I got it working!

Here's my full code:

        // Search button has been clicked - let's do some AJAX, baby!
        $("#searchbutton").click(function(){
          $("#animal_table").slideUp("slow");
          $("#searchbox:visible").slideUp("slow");
          $("#show_search").show();
          $("#hide_search").hide();
          $("#animal_table").load("/includes/catalogue/getlots.php",{
            start: "0",
                show: "200",
                year: "<?php echo $thispage['year']; ?>",
                sire_id: document.getElementById("sire_id").value,
                horn: document.getElementById("horn").value,
                ss: document.getElementById("ss").value,
                milk: document.getElementById("milk").value,
                ci: document.getElementById("ci").value,
                ebv200d: document.getElementById("ebv200d").value,
                ebv400d: document.getElementById("ebv400d").value,
                ebv600d: document.getElementById("ebv600d").value,
                text: document.getElementById("text").value
                },function(){
              $("#animal_table").slideDown("slow");
              // search for new a elements so loaded stuff can be clicked
                  $("#animal_table").find("a").click(function(){
                        //alert(this.id);
                        $("#animal_detail").slideUp("slow");
                        
$("#animal_detail").load("/includes/catalogue/showdetail.php",{
                          lot_id: this.id
                        },function(){
                          $("#animal_detail").slideDown("slow");
                        });
                        return false;
                  }); // close click function on a
                }); // close function that's called at and of AJAX call
        });


On 08/08/06, Jason Foss <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Reading through the archives I have found out why I can't apply the
> click function to content I have added via .load - however I can't get
> any of the solutions to work! (And I don't fully understand them which
> doesn't help either!)
>
> In simple terms, does anyone have a way for a newbie to re-apply event
> handlers to content that's been called via .load?
>
> Here's what I have:
>
>         // Search button has been clicked - let's do some AJAX, baby!
>         $("#searchbutton").click(function(){
>           $("#animal_table").slideUp("slow");
>           $("#animal_table").load("/includes/catalogue/getlots.php",{
>             start: "0",
>                 show: "200",
>                 year: "<?php echo $thispage['year']; ?>",
>                 sire_id: document.getElementById("sire_id").value,
>                 horn: document.getElementById("horn").value,
>                 ss: document.getElementById("ss").value,
>                 milk: document.getElementById("milk").value,
>                 ci: document.getElementById("ci").value,
>                 ebv200d: document.getElementById("ebv200d").value,
>                 ebv400d: document.getElementById("ebv400d").value,
>                 ebv600d: document.getElementById("ebv600d").value,
>                 text: document.getElementById("text").value
>                 },function(){
>               $("#animal_table").slideDown("slow");
>                   $(document).ready(); // my dumb hack which doesn't work
>                 });
>         });
>
>
> Cheers!
> Jason
>
> --
> Jason Foss
> http://www.almost-anything.com.au
> http://www.waterfallweb.net
> Windows Messenger: [EMAIL PROTECTED]
> North Rockhampton, Queensland, Australia
>


-- 
Jason Foss
http://www.almost-anything.com.au
http://www.waterfallweb.net
Windows Messenger: [EMAIL PROTECTED]
North Rockhampton, Queensland, Australia

_______________________________________________
jQuery mailing list
[EMAIL PROTECTED]
http://jquery.com/discuss/

Reply via email to