Skip to main content
Inspiring
July 30, 2019
Answered

Disable multiple "Run" executions.

  • July 30, 2019
  • 2 replies
  • 910 views

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);

}

This topic has been closed for replies.
Correct answer Manan Joshi

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

2 replies

Trevor:
Legend
July 30, 2019

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

Manan JoshiCommunity ExpertCorrect answer
Community Expert
July 30, 2019

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

-Manan