hook into submit (client side) before execution
-
we used to modify submit form in javascript / jQuery during submit to enhance it with “custom” input html tag with some calculated values using javascript and wp_enqueue_script to transfer it to server side (php)
but after upgrade to 5.4 (and newer) it doesn’t work anymore
wp_enqueue_script(‘custom-script’, plugin_dir_url(__FILE__) .
‘/custom-script.js?fer=222’, array(‘jquery’), “2”);(function ($) { $(function () { $("form").each(function () { var form = $(this); if ($(this).find("input[name=custom]").size() > 0) { $(this).submit(function (e) { var arr = []; $(this).find("input[name=custom]").each(function () { arr.push({ email: $(this).val(), price: $(this).closest("table").find(".cf7-calculation").val() }); }); console.log(arr); if (form.find("[custom-input-field]").size() == 0) { form.append("<input type='text' name='custom-input-field'/>"); } form.find("[name=custom-input-field]").val(JSON.stringify(arr)); return true; }); } }); }); })(jQuery)now it looks javascript is executed after submit…
what is current preferred way to inject into submit action before it is executed on client side
thank you
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘hook into submit (client side) before execution’ is closed to new replies.