1

I am using fancybox 1.2.6 I want to avoid closing of fancybox when you click on the outside of the content.. But nothing is working.. can you help me with this.. and one more thing.. i am trying to trigger the fancybox close function when you submit a form..How can i do that ?

Erik
  • 20,526
  • 8
  • 45
  • 76
AquaGirl
  • 21
  • 3

3 Answers3

2

set hideOnOverlayClick to false in your options when creating your fancyBox. Here's an example:

$("a.zoom1").fancybox({
    'hideOnOverlayClick'    :       0  
});

To close it on the submit of your form, bind an onsubmit event to that form, and in that onsubmit function use:

$.fn.fancybox.close();

to cause the fancybox to close.

Erik
  • 20,526
  • 8
  • 45
  • 76
  • Hello Erik i tried to close the fancybox as you said.. but i am getting some error msg "opts is undefined" and it doesn't close also...can you figure it out what it could be / – AquaGirl Jan 22 '10 at 06:46
  • I can't figure it out based on that error; I've never closed FB with a link of my own before - I lifted that from the fb website. – Erik Jan 22 '10 at 07:55
0

OPTS IS UNDEFINED

Today I had the task to find out why fancybox is not working on some old site, after debugging for some time, I found that lines of code that initialized the fancybox were commented.

 $("a.calendar_item_edit").fancybox({
        'hideOnContentClick': false,
        'frameWidth': 215,
        'frameHeight': 300
        });

Stripped down the comments, and all was working great. This is fancy box 1.2.0.

DarkoM
  • 335
  • 4
  • 5
0

To prevent the fancybox closing you can try adding these values:

$("a.zoom1").fancybox({
'hideOnOverlayClick': false,
'hideOnContentClick': false
                });

I don't know what language you want to use to close the fancybox, but to close the it from ASP.Net - add an attribute to the form submit button:

btnPostcode.Attributes.Add("onclick", "javascript:parent.$.fancybox.close();");
markpsmith
  • 4,860
  • 2
  • 33
  • 62