tags:

views:

47

answers:

1

Hi All

I can't seem to get this working, some help would be greatly appreciated.

I have a page with the following code:

$('.editname').click(function (e) {
  var src = "test.html";
  $.modal('<iframe src="' + src + '" height="480" width="640" style="border:0">', {
   closeHTML:"<div class='no simplemodal-close'>Close</div>",
   containerCss:{
    backgroundColor:"#fff",
    border:"10px solid #333",
    height:480,
    padding:"10px",
    width:640
    },
   opacity:50,
   overlayCss: {backgroundColor:"#fff"},
   onShow: function (dialog) {
    $('.saveit', dialog.data[0]).click(function () {
     // close the dialog
     $.modal.close();
    });
   }
  });
 });

The code for test.html (the contents of the modal window) is:

<body>
<h1>Test</h1>
<div class='pointer spacertop'><a href="#" class="saveit">Save</a></div>
</body>

The modal window appears, however clicking on the Save button (class saveit) in the modal window does not fire the click function. It does nothing. Please help.

Thank you in advance.

A: 

Since you are binding to an element in the iframe, you need to get back to the "parent" modal object to close the dialog:

$('.saveit', dialog.data[0]).click(function () {
    // close the dialog
    parent.jQuery.modal.close();
});
Eric Martin