Skip to main content

Hi, quick bit of help…


Since the recent update I’ve spent most my time recreating a multi-step script so that it will run without reliance on any inbuilt jquery. As we already load version 1.12 we are trying to keep the pages light by not loading two versions of jquery.


I’ve been trying to submit the form through use of $('.lp-pom-form form').submit(); however this seems to lead to a json error… {"protected_assets":{}}

In the past I’ve come across this problem and my janky solution was to hide the original submit button, replicate it with another button… then once I wanted to submit the form I’d trigger a click on the original button.

I don’t really want to use this as a standard method to programmatically submit forms as it requires a good chunk of setup or specific coding to do…


In this new update how do I programmatically submit a form successfully without use of the inbuilt jquery?

Pure JS doesn’t work either

var x = document.getElementsByTagName(“form”);

xr0].submit(); //form submission


And just for the sake of completeness… here’s a simple example… Button fires $(‘form’).submit();


https://dev.digitaloyster.co.uk/tims-tests/bb.html


Thank you, Bruna from support… looks like we have the solution…


Just for the sake of completeness posting it here… (nothing worse than googling for a problem to find hundreds of posts of people asking the same question with no resolution)


          const myForm = document.forms.0];

var event = new Event('submit', {
'bubbles' : true, // Whether the event will bubble up through the DOM or not
'cancelable' : true // Whether the event may be canceled or not
});

myForm.dispatchEvent(event);

The above code to be used in place of lp.jQuery(‘form’).submit();


Reply