|
2 | 2 | (function ($) {
|
3 | 3 | function mc_beforeForm() {
|
4 | 4 | // Disable the submit button
|
5 |
| - $('#mc_signup_submit').attr('disabled', 'disabled'); |
| 5 | + $('.mc_signup_submit_button').attr('disabled', 'disabled'); |
6 | 6 | }
|
7 | 7 |
|
8 |
| - function mc_success(data) { |
| 8 | + function mc_success(data, status, xhr, submittedForm) { |
| 9 | + let form = $(submittedForm); |
| 10 | + if (!submittedForm || !form) { |
| 11 | + form = $('.mc_signup_form'); |
| 12 | + } |
| 13 | + |
9 | 14 | // Re-enable the submit button
|
10 |
| - $('#mc_signup_submit').removeAttr('disabled'); |
| 15 | + $('.mc_signup_submit_button').removeAttr('disabled'); |
11 | 16 |
|
12 | 17 | // Put the response in the message div
|
13 |
| - $('#mc_message').html(data); |
| 18 | + form.find('.mc_message_wrapper').html(data); |
14 | 19 |
|
15 | 20 | // See if we're successful, if so, wipe the fields
|
16 | 21 | const reg = /class=(["'])mc_success_msg\1/i;
|
17 | 22 |
|
18 | 23 | if (reg.test(data)) {
|
19 |
| - $('#mc_signup_form').each(function () { |
| 24 | + $(form).each(function () { |
20 | 25 | this.reset();
|
21 | 26 | });
|
22 |
| - $('#mc_submit_type').val('js'); |
| 27 | + |
| 28 | + $('.mc_submit_type').val('js'); |
23 | 29 | }
|
| 30 | + |
24 | 31 | window.scrollTo({
|
25 |
| - top: document.getElementById('mc_signup').offsetTop - 28, |
| 32 | + top: parseInt(form.offset().top, 10) - 28, |
26 | 33 | behavior: 'smooth',
|
27 | 34 | });
|
28 | 35 | }
|
29 | 36 |
|
30 | 37 | $(function ($) {
|
31 | 38 | // Change our submit type from HTML (default) to JS
|
32 |
| - $('#mc_submit_type').val('js'); |
| 39 | + $('.mc_submit_type').val('js'); |
33 | 40 |
|
34 | 41 | // Attach our form submitter action
|
35 |
| - $('#mc_signup_form').ajaxForm({ |
| 42 | + $('.mc_signup_form').ajaxForm({ |
36 | 43 | url: window.mailchimpSF.ajax_url,
|
37 | 44 | type: 'POST',
|
38 | 45 | dataType: 'text',
|
|
0 commit comments