0

I am developing ASP.NET 4.0 application runs in Facebook App. I'am using jQuery FancyBox to show some PopUps. I can easily show modal, but when I try to close or try to handle which button (Yes/No) clicked, problems occur. Searched many sites, found many solutions, but nothing changed. For example, this is code which I use to show modal

This is HTML Part

<div id="uyariIki" class="uyariModal">
    <table width="100%" border="0" cellspacing="0" cellpadding="15">
         <tr>
       // Some Mesages here
         </tr>
         <tr>
             <td align="center" valign="middle"><a class="modalTamam-button" href="#"  onclick='$.fancybox.close'>Tamam</a></td>
         </tr>
    </table>
</div>

I used different codes on onclick event such as

$.fancybox.close()

OR

parent.jQuery.fancybox.close();

OR

parent.$.fancybox.close();

But these are didnt work. When I hit "Tamam" button, LightBox is closing and suddenly showing again like an infinite loop or postback.

I also tried to close it from Javascript such as:

function CloseFancyBox() {
    $("#uyariIki").fancybox().trigger('close');
}

But ofcourse this one also didnt work :)

Checking http://fancybox.net/api to see options, $.fancybox.close is located in this site. But its not working.

So, how can I close FancyBox, when I click "Tamam" button on FancyBox Modal

Second question is; How can I handle which button pressed (Yes/No)? (I can provide codes of this modal)

I can provide another information if needed. Thanks.

4

3 回答 3

1

你写;

  <td align="center" valign="middle">
      <a class="modalTamam-button" href="#"  onclick='$.fancybox.close'>Tamam</a>
  </td>

尝试:

$.fancybox.close();

或试试这个:

javascript:jQuery.fancybox.close();

于 2012-08-17T07:45:31.683 回答
0

在按钮单击事件上使用它:-

Page.ClientScript.RegisterStartupScript(typeof(Page), "close", string.Format("<script type='text/javascript'>{0}</script>", "parent.$.fancybox.close() ;"));
于 2013-11-21T14:17:34.470 回答
-1

在 aftershow 回调中试试这个: 注意:('close') 是你想要执行 close() 函数的按钮的 ID。

 $('#close').click(function(e) {
                    $(".fancybox-close")[0].click();
                })

于 2015-05-19T05:27:25.593 回答