I have two questions and I would appreciate it if you help friends who are experiencing javascript.
Starting a payment step using the Run JavaScript action of the Toolbox plugin. This code allows me to execute the authorizaton process and send the data to the sandbox environment.
My first question, as you can see in the .gif, does not start the process with a single click. You need to click 2-3 times, how can I fix this?
My second question is that I still have to use a button when I get the payment result.
When page is loaded Run Javascript doesnât work, I can access the payment result with a button (and again with 2-3 clicks). How can I handle this?
I need to be able to show my payment result to my users without clicking on anything.
Without taking a look at your editor, its a shot in the dark, but it looks like you may be having issues because the DOM has not rendered before executing your javascript.
You can use jquery in an html element on your page instead of using the âwhen page is loadedâ bubble workflow action. If you apply $( document ).ready() , the javascript contained within that function will only run once the page DOM is ready for JavaScript code to execute.
$( document ).ready(function() {
//insert any functions, variables, etc. here
console.log( "ready to load custom javascript!" );
});
Alternatively, you can also use $( window ).on( "load", function() { ... }) instead if you need the entire page (images, iframes, etc) to load first, in addition to the DOM
@supernaturally is possibly correct about this. But you donât need to throw more custom code into your page via HTML elements to accommodate page loading.
Just donât fire your workflow(s) that use Run JavaScript until Page is Loaded. (So your workflows have conditions on them. Similarly, elements on the page like your button should remain unclickable until the page is fully loaded (use the conditions tab to style them).
Another useful thing is to explore the Expression element instead of Run JavaScript to execute your custom code. Since thatâs an element, you can just put a placeholder in the expression code field (like // the code we execute is over in the conditions tab) and then, in the conditions tab for the Expression element, you have a condition like âWhen Page is Loadedâ and youâll find that expression code is one of the things you can change on that condition.