IntroductionThis page describes callbacks available for use in ModalBox. DetailsThere 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(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.
|
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.
In response to MolikJain?, in your Modalbox.show function add the line method: 'post' it is defaulted to $GET. <a href="URL HERE" onclick="Modalbox.show(this.href, {title: this.title, width: 300, method: 'post'}); return false;">
how to validate html form?, submit button continuing without fill the field
What Jusinasu said on Jun 10 2008 helped me immensely. The callbacks just don't call at the right time if you do that.
Hello. I'm trying to using modalbox in my project. I have this environment;
I have a form where the user must fill some required fields; then he needs to check some not required options and i'ld love to open a modalbox; the user can check some checkbox; when he submit the form i must refresh a portion of the parent page.
So in my parent page i wrote:
<a href="#" id="eleCate" name="eleCate" class="button" onclick="Modalbox.show('elencoCategorie.controller?modelId=choosenCategories', {title: '<fmt:message key="chooseCategories"></fmt:message>', beforeHide: function(){ window.serializedForm = Form.serialize('ilForm'); }, afterHide: function() { alert('serializedForm'+serializedForm); $('paginaPopup').update(serializedForm) }}); return false;">Elenco categorie</a>
where in Form.serialize i passed the id/name of the form presents in my modalbox. In my modalbox i have: <!-- elencoCategorie.jsp --> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%> <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <form action="#" method="post" id="ilForm" name="ilForm" > <c:choose>
</c:choose> <input type="submit" value="conferma" onclick="submitts()" class="button"> <a href="#" onclick="Modalbox.hide(); return false;" class="button"> <fmt:message key="btnCancel"/> </a> </form> <!-- Fine elencoCategorie.jsp -->For now the submit does nothing; i'ld love to update the parent dom portion as in the sample Modalbox beforeHide callback test but it seems not work...am i missing anyhting? Regards,
Hi. This is grate lib!!! But, I have some problem. How can I change position of window?
Thanks!
Andrew.
Same question as andrew I would like to reposition the modalbox so it comes out of the bottom or it does not come out of the top of the page, say same position of the browser but different position in the page, how can I do this? Is it even possible?
Thanks,
Archie.
hi,
i have to submit modalbox form on the same file for example, it is registration file once it is stored user details after validation checking then i want to close current modalbox and open next screen is say it email varification modalbox. So, i have opened this next modalbox on call back "afterHide" of current modalbox hide but it keeps this call back for all next newly opened screen and when i clicked on close (X), i am not able close this newly appeared modalbox and show me repeated loop for showing and hiding event of modalbox.
script like this once the modalbox submit on same page: 1. check validations 2. store value to database 3. close the current modalbox and set newly modalbox.show() on callback of "afterHide" on hide()of curr. modalbox means
Modalbox.hide({afterHide:function(){Modalbox.show(next_URL,{title:'title',width:'300',height:'200',method:'get'})}});
Anyone here who will help me to digout this issue? or what is the correct solution for it?
Please provide me solution as earliest as possible, if anyone have
Thanks a lot, Keyur
Hi to all,
i'm trying to hide the Modalbox popup afterHide event, this is the code:
public static native void showConfirmPopup (String title, String content, ConfirmCallback? callback) /-{ \'Yes\' onclick=\"result=this.value; Modalbox.hide({afterHide: function (btnID) {callba...@org.ratis.gui.system.client.effects.TBKEffect.ConfirmCallback?::execute (Ljava/lang/String;)(result)}}) \" /> or <input type=\'button\' value= \'No\' onclick=\" result=this.value; Modalbox.hide() \" /></div>', {title: title, width: 300}); /;
where is called the java method for the callback:
public static interface ConfirmCallback? {
With this code i get the error: missing ) after argument list.
If i try to replace the code within the hide method with a simple alert:
$wnd.Modalbox.show('<p>content</p><input type=\'button\' value=\'Yes\' onclick=\"result=this.value; Modalbox.hide({alert(result)}) \" /> or <input type=\'button\' value=\'No\' onclick=\" result=this.value; Modalbox.hide() \" /></div>', {title: title, width: 300});
everything works good, but if i have the java method call: callba...@org.ratis.gui.system.client.effects.TBKEffect.ConfirmCallback?::execute (Ljava/lang/String;)(result)
the code raise that strange error.
I tried to remove the ";" at the end of Ljava/lang/String; but i get a new error: callback is not defined
Could someone help me please? it's really strange and annoying..
thanks very much
To these following queries... << Comment by andrew2686, Jul 24, 2009 Hi. This is grate lib!!! But, I have some problem. How can I change position of window?
Thanks!
Andrew.
Comment by archie.sheran, Jul 29, 2009 Same question as andrew I would like to reposition the modalbox so it comes out of the bottom or it does not come out of the top of the page, say same position of the browser but different position in the page, how can I do this? Is it even possible?
Thanks,
Archie. >>
What i did :
this.MBwindow).setStyle({left: (($(this.MBoverlay).getWidth() - $(this.MBwindow).getWidth()) / 2 ) + "px"}); $(this.MBwindow).setStyle({top: 140 + "px"}); },
regards anvar
Hello,
I'm trying to combine Modalbox and CKEditor. From now it's working at 90%, i can load a box with ckeditor insite, write a news and post it. My problem is that if i close the modalbox without submitting the form, when i want to reshow the modalbox the ckeditor is no more present.
Any idea ?