Results 1 to 6 of 6

Thread: Form confirmation in Mediabox

  1. #1
    User
    Join Date
    07-08-10.
    Location
    Madrid, Spain
    Posts
    145

    Default Form confirmation in Mediabox

    Hello

    I'd like to know how to do to display the confirmation of a form in a mediabox.

    Thanks in advance
    Eric
    Contao 2.8 -> 3.0
    Evizer Web Agency

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Form confirmation in Mediabox

    I can at least point you in the right direction. Typically it involves 2 parts:

    1. Intercept/stop the form submission using MooTools and submit the form via AJAX instead:
    http://mootools.net/docs/core/Request/Request
    http://mootools.net/docs/more/Forms/Form.Request

    2. Upon getting a success response, manually open a new Mediabox, pointing to either a separate thank you page, or some inline content.
    http://iaian7.com/webcode/mediaboxAdvanced/#scripting

    There should also be some examples online if you do a search.
    Brian

  3. #3
    User
    Join Date
    07-08-10.
    Location
    Madrid, Spain
    Posts
    145

    Default Re: Form confirmation in Mediabox

    Thank you I'll try this way.

    If someone have an example it will be welcome !
    Eric
    Contao 2.8 -> 3.0
    Evizer Web Agency

  4. #4
    User
    Join Date
    07-08-10.
    Location
    Madrid, Spain
    Posts
    145

    Default Re: Form confirmation in Mediabox

    With your indications I found the following page which works:
    http://fourmilestomay.com/2009/submitti ... xadvanced/

    But I'd like to know if there is a way to get the page alias in the javascript of the template page as the {{page::alias}} tag doesn't work;
    Is it possible to get the form ID as well automaticaly.

    With this completement it will be completely flexible.

    Thank you
    Eric
    Contao 2.8 -> 3.0
    Evizer Web Agency

  5. #5
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Form confirmation in Mediabox

    I think I understand -- you want the Alias and CSS ID so you can plug into the JavaScript, correct?

    You actually don't need either to do this. Instead, give any form you want to submit via AJAX a CSS class (which you can add in the backend CSS ID/class field). If you give it something like "ajax" you can do the following:

    Code:
    <script>
    	window.addEvent("domready", function() {
    		// When any form with a class of "ajax" gets submitted...
    		$(document.body).getElements("form.ajax").addEvent("submit", function(e) {
    			// Stop sending, and set some AJAX options...
    			e.preventDefault().target.set("send", {
    				// For example, on a successful submission...
    				onSuccess: function(response) {
    					// Here's where you do your other stuff, like opening a Mediabox window.
    					// "response" will hold the HTML content of the thank you page, BTW.
    				}
    			// OK, everything's set. Go ahead and submit...
    			}).send();
    		// Note that you don't even need to pass the "action" this way
    		// (MooTools figures it out for you), 
    		// so you don't need the alias anymore.
    		});
    	});
    </script>
    Brian

  6. #6
    User
    Join Date
    07-20-09.
    Location
    Middlesbrough - United Kingdom
    Posts
    95

    Default Re: Form confirmation in Mediabox

    Did you have any luck with this, I've noticed there's an extension to do the same thing but only for versions 3+. I'm trying to do this in 2.11.11. I have tried the script you suggested but with no luck, any help would be greatly appreciated.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •