|
|
CallBacks
Callbacks reference
Introduction
This page describes callbacks available for use in ModalBox.
Details
There are couple of callbacks supported by ModalBox. Here they are:
- beforeLoad — fires right before loading contents into the ModalBox. If the callback function returns false, content loading will skipped. This can be used for redirecting user to another MB-page for authorization purposes for example.
- afterLoad — fires after loading content into the ModalBox (i.e. after showing or updating existing window).
- beforeHide — fires right before removing elements from the DOM. Might be useful to get form values before hiding modalbox.
- afterHide — fires after hiding ModalBox from the screen.
- afterResize — fires after calling resize method.
- onShow — fires on first appearing of ModalBox before the contents are being loaded.
- onUpdate — fires on updating the content of ModalBox (on call of Modalbox.show method from active ModalBox instance).
IMPORTANT NOTICE. Each callback is being removed from options of the ModalBox after execution.
Examples
- Modalbox.show(title, url, {afterLoad: function() { alert('Content loaded successfully') } }); - after contents of the page located at specified URL will be loaded into ModalBox, alert will appears on the screen.
- Modalbox.hide({afterHide: function() { alert('Modalbox is now hidden') } }); - you can pass callback to any ModalBox method (show, hide, resize). This will show alert after ModalBox disappears.
Sign in to add a comment

hi
et
Hi! Is it or will be possible to launch callbacks when you click on overlay; similar to afterHide method.
I mean; something which you can switch on/off to launch some functions in case of clicking on overlay.
Of course I tried to modify the code and I was able to launch some functions afert clicking on overlay, but I had no influence on working or not working of fuctions which I was calling back.
Thank you for your response. Regards and thanks for good piece of code.
Is it possible to call a user defined javascript function from inside a call back.
Hi,
I want to recieve form post values from one modalbox to another consequent modalbox form.
I used $POST in php, but it is not receiving values.
What to do.
Thanks in advance.
Molik Jain
All calbacks don't like to get function names with brackets. Dont define afterHide: your_function_name() of the event will not work. this thing troubled me for a few hours.
afterLoad doesn't seem to work in IE 7? My code is:
Modalbox.show('myURL', {title: 'Click the location on the map where this venue is located.', width: 650, height:550, afterLoad: function() { alert('Content loaded successfully')}});
This is on an onClick event in a href.