views:

33

answers:

1

Hello,

I have an iframe loaded and I want to attach a click event to every anchor. The modal is triggered from a link.

UPDATED:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
  <title>Simple Modal Test</title>
  <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
  <script type="text/javascript" src="jquery.simplemodal-1.3.5.js"></script>
</head>
<body>
<a id="showModal" href="#">Trigger Simple Modal</a>
<script type="text/javascript">
$(function(){
  $('#showModal').click(function(e){
    $.modal('<iframe src="mylinks.html'" height="400" width="600" style="border:0">', { 
      onShow:function(dialog){ 
        $('a', dialog.data).click(function(){ 
          // do something
          alert('You clicked me!'); 
        });
      }
    });
    return false;
    });
  });
  </script>
</body>
</html>

This is what I have in mylinks.html:

<a href="http://www.google.com" target="_new">Google</a>
<a href="http://www.yahoo.com" target="_new">Yahoo!</a>

I am using jQuery 1.4.2 and Simplemodal version 1.3.5. I also tested this code in 1.3.2 and have the same problem even in FF or IE7. Could someone please tell me what I am doing wrong?

Thanks! J

A: 

If I am understanding you, I think you want something more like:

$('#show').click(function() {
 $('#myURL').find('a').click(function(event) {
  alert('I was clicked');
 });
})
Yes, I want more... this event will not trigger the iframe.
nolabel