0

I have a list of dialog boxes which I want to open when there assosciated icon is clicked on but not write a .click() function for each dialog. At the moment my html looks like this.

<ul>

<li>
    <img src="e_gift_ss/design_2_1.jpg" alt="Screenshot 1"/> 
    <img src="e_gift_ss/design_2_2.jpg" alt="Screenshot 2"/> 
    <img src="e_gift_ss/design_2_3.jpg" alt="Screenshot 3"/> 
    <img src="e_gift_ss/logo_designs.jpg" alt="Screenshot 4"/> 
</li>

    <li class="portfolio_link"><img src="link_img/e_gift.png" alt="e-Gift Voucher" class="icon png" id="e_gift_link"/></li>

    <li>
      <article>
        <h4>Acer E-Gift Voucher</h4>
        <p>Designed as a web portal for a after sale marketing promotion.</p>
      </article>
    </li>

  </ul>

and my jquery looks like this

$('.portfolio_link').css({backgroundPosition: "-480px 0"});

$('.icon').parent().prev().dialog({resizable:false,autoOpen:false,draggable:false,width:860,height:pageheight,modal:true});

$('icon').click(function(){$(this).parent().prev().dialog('open');

});

Making the li element a dialog works fine but the .click function will not open the dialog.

Any ideas would be great

Cheers

Psylant
  • 93
  • 1
  • 10

1 Answers1

1

Your last line of javascript code says:

$('icon').click(function(){$(this).parent().prev().dialog('open');

Maybe you did forget the dot before the classname icon?

So it should be

$('.icon').click(function(){$(this).parent().prev().dialog('open');

Or is this just a typo?

Dennis
  • 14,210
  • 2
  • 34
  • 54
  • nah that was just my mistake copying it accross – Psylant Sep 04 '11 at 12:29
  • You should check out in Firefox with firebug. I guess when you first create the UI-Dialog, this changes the DOM-Structure, so you cannot reference that dialog element with the parent().prev() selector anymore. at least in my testcase, the dialog is appended to the body, and the list-Element that served as the souce-element for the dialog is removed. – Dennis Sep 04 '11 at 12:58
  • thanks heaps that makes sense I'll try and find a work around I guess – Psylant Sep 04 '11 at 13:59