How to disable closing the box from clicking anywhere on screen?

1,182 views
Skip to first unread message

jasondavis

unread,
Jan 13, 2010, 10:48:27 AM1/13/10
to facebox
How can I make it where you can only close the box by clicking a close
button? I already removed the escape key closing action but it will
still close if I click anywhere outside the box and I need to disable
that somehow?

Arka15

unread,
Jan 13, 2010, 7:00:46 PM1/13/10
to facebox
Hi.

other autor write :


Sometimes we may require to make our facebox modal i.e do not allow
the background to be clickable when facebox is loaded.

I have one simple solution. Hope it helps you guys out there..

1.Add one parameter in settings

$.extend($.facebox, {
settings: {
opacity : 0.5,
overlay : true,
modal : true, //New parameter
........

}

2. Modify the function showOverlay()
replace the line .click(function() { $(document).trigger
('close.facebox') })
with .click(function() {
if ($.facebox.settings.modal != true)
$(document).trigger('close.facebox')
})

Make sure you set the value of opacity between 0 and 1, and the
overlay value to true.
Enjoy!

Arka15

unread,
Jan 13, 2010, 7:01:52 PM1/13/10
to facebox
Hi.

other autor write :


Sometimes we may require to make our facebox modal i.e do not allow
the background to be clickable when facebox is loaded.

I have one simple solution. Hope it helps you guys out there..

1.Add one parameter in settings

$.extend($.facebox, {
settings: {
opacity : 0.5,
overlay : true,
modal : true, //New parameter
........

}

2. Modify the function showOverlay()
replace the line .click(function() { $(document).trigger
('close.facebox') })
with .click(function() {
if ($.facebox.settings.modal != true)
$(document).trigger('close.facebox')
})

Make sure you set the value of opacity between 0 and 1, and the
overlay value to true.
Enjoy!

On Jan 13, 11:48 am, jasondavis <friendproj...@gmail.com> wrote:

jhsveli

unread,
Jan 18, 2010, 8:03:34 AM1/18/10
to facebox

In order to not edit facebox.js directly, I did like this:

//Extend facebox (As per Arka15's suggestion:
$.extend($.facebox.settings, { modal : true });

//Alter default behaviour (remove standard click behaviour, attach our
own)
$(document).bind('loading.facebox', function() {
$("#facebox_overlay").unbind("click").click(function()
{
if (!$.facebox.settings.modal) {
$(document).trigger('close.facebox');
}
})
})

hawkmanjacko

unread,
Mar 1, 2010, 11:39:35 AM3/1/10
to facebox
Hi Arka15 - thanks for your solution - it works the treat and is
exactly what I was after!

Cheers for posting your solution!

Much appreciated,

Jamie

> > that somehow?- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages