V
V
Viorel2015-04-17 09:11:03
Drupal
Viorel, 2015-04-17 09:11:03

How to get confirmation message in modal window?

Created a form in a modal window / Drupal 7, Webform, Colorbox, Colorbox Node, Webform Ajax/
When you click on the link, the window opens as it should.
And when submitting the form, a full page with the same form opens.
The message is not shown.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Andreev, 2015-04-17
@b0nn1e

If after sending the handicap, on the new page you don’t have the necessary text in the pop-up window, then you have a problem on the server side, if you need something that would just work without reloading, then wrap the form in a div with some ID like this:

<div id="callback">
  <form ....>
     .....
  </form>
</div>

Further in JS:
$(function() {
  function ajaxForm(BlockID) {
        if ($('#' + BlockID + ' form:first').length > 0) {
            $(document).on('submit', '#' + BlockID + ' form:first', function () {
                var data = $(this).serialize();
                $.ajax({
                    data: data,
                    type: "post",
                    url: document.location.href,
                    success: function (answer) {
                        var start = answer.indexOf('<body');
                        var end = answer.indexOf('</body>')+7;
                        answer = answer.substring(start, end);
                        answer = $(answer).find('#' + BlockID).html();
                        $('#' + BlockID).html(answer);
                    }
                });
                return false;
            })
        }
    }

    ajaxForm('callback');
});

This is of course redneck code, but in principle it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question