Copy link to clipboard
Copied
Hi,
I create a panel and I noticed that since it does some calculation after I press my main "Run" button:
The user can mistakenly think it is not running and press the "Run" button again which may cause the main function to run several times.
How can I allow only a single press of this button?
The relative functions are:
in the main.js i use:
csInterface.evalScript('createSplitExportWrapper(' + JSON.stringify(panelData) + ')');
in jsx i use:
function createSplitExportWrapper(panelData) {
var scriptFile = "/wrappers/createSplitExportWrapper.jsx";
var runScript = File(scriptDir + scriptFile);
// alert("scriptDir:\n" + runScript);
$.evalFile (runScript);
}
One way would be to disable the button or element on whose click you call the evalscript method and then reenable it once the callback is called. Something like the following should work
//Disable your button
csInterface.evalScript('createSplitExportWrapper(' + JSON.stringify(panelData) + ')', function()
{
//Reenable your button
});
-Manan
Copy link to clipboard
Copied
One way would be to disable the button or element on whose click you call the evalscript method and then reenable it once the callback is called. Something like the following should work
//Disable your button
csInterface.evalScript('createSplitExportWrapper(' + JSON.stringify(panelData) + ')', function()
{
//Reenable your button
});
-Manan
Copy link to clipboard
Copied
Can also use JSX.js A Game Changer in Adobe HTML Extensions Development? – Creative-Scripts.com but you'll still have to use some form of disable / enable which can either be ideally setting the buttons atribute
btn = document.getElementById("Button");
btn.disabled = true;
and then on call back btn.disabled = false;
The other way would be
if (!disabled) {
disabled = true;
evalScript('theScript', function(){disabled = false;});
}
Unless you have good reason then the 1st method is better