tags:

views:

1135

answers:

3

Hey guys,

I have a few different divs with different projects and names. Each one has a unique name, and I would like that when a user clicks on one, that it loads the appropriate page into the popupContainer div. For some reason it is not calling though.

This is the Jquery:

$(document).ready(function(){
    //Find & Open
    $(".projectThumb").click(function(){
        htmlName = $(this).find("img").attr("name");
        $("#popupContainer").load(htmlName + ".html");
            });
    //Close property
    $("a.close").live("click", function(){
  $("#popupContainer").empty();
  });
});

This is the html:

<div id="content">
    <div class="projectThumb">
    <img src="/img/aeffect_button_static.gif" width="146" height="199" class="button" name="aeffect" alt="" />
    <p class="title">A.EFFECT: Film Poster</p>
    </div>
    <div class="projectThumb">
    <img src="/img/lova_button_static.gif" width="229" height="199" class="button" name="lova" alt="" />
    <p class="title">Lova &ndash; Summer 07&rsquo; &ndash; Titles</p>
    </div>
</div>
<div id="popupContainer"></div>
A: 

Tag

<img ... >

has no attribute "name" (only form and its components), use "id" :)

Rin
I tried ID and its the same problem.
Anthony
A: 

Your not closing your 1st click function:

$(document).ready(function){
 //Find & Open
 $(".projectThumb").click(function(){
   htmlName = $(this).find("img").attr("name");
   $("#popupContainer").load(htmlName + ".html");
 }); <-- needed

 //Close property
 $("a.close").live("click", function(){
   $("#popupContainer").empty();
 });
});
Colin
Almost there but no banana... the first function passed to "ready" is ill-defined
BlackMael
Sorry that was my mistake, I just mistyped it, I edited the original to reflect my code.
Anthony
A: 

You're not closing your 1st click function and you're not opening the ready(function(){...}) correctly either:

$(document).ready(function(){ // <-- added missing open parens
 //Find & Open
 $(".projectThumb").click(function(){
   htmlName = $(this).find("img").attr("name");
   $("#popupContainer").load(htmlName + ".html");
 }); // <-- added needed closing function

 //Close property
 $("a.close").live("click", function(){
   $("#popupContainer").empty();
 });
});
BlackMael
corrected these as they were typos when I was inputting the code to Stack Overflow.
Anthony
Hmm... Now I'm confused as it works for me..
BlackMael