Hello Cédric,
Have you tried to load the Mailjet JS also on the other pages (not only on the page with widget) and see what happens?
Best regards,
Mailjet Team
Thread Starter
Ced
(@cedriccharles)
Hello !
I have loaded the JS on all pages but as the “submit” button is not in the page on the first load, it doesn’t work after the AJAX load. I need to trigger the script on page change. Do you have something for that ?
Thank you in advance 🙂
Hello again,
We don’t have the same setup as you so we are not able to test properly, but would you try a quick fix?
Try to replace the contents of this file in the plugin: assets/js/ajax.js
with the following code: https://pastebin.com/Vu5ujTHy
Please let me know if it works.
Best regards,
Mailjet Team
Thread Starter
Ced
(@cedriccharles)
Hi @mailjet 🙂 !
Thank you for your answer ! It doesn’t work, because you do the click on an element that is still not in the page. But with the following code, it works because we do the click event on the “body”, which is all the time present, in every pages of course 😉 :
jQuery(document).ready(function ($)
{
$('body').on('submit', '.subscribe-form', function (e)
{
e.preventDefault();
var $el = $(this);
var loading = '<p><img src="' + WPMailjet.loadingImg + '" alt="Please wait..."></p>';// Loading state
var $res = $el.parent().find(".response").html(loading);// Clear previous messages
$.post(WPMailjet.ajaxurl, $el.serialize(), function (data)
{
$res.html(data);
});
});
$('body').on('click', '.widget-control-close', function (e)
{
var $res = $(this).closest('form').find(".mailjet_subscribe_response");
if (jQuery.type($res.html()) !== undefined)
{
$res.hide();
}
});
});
Could you do something about it ?
Should be fixed in v. 4.3 of the plugin. Please let us know if the problem persists.