• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Disable multiple "Run" executions.

Engaged ,
Jul 30, 2019 Jul 30, 2019

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

}

Views

736

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 30, 2019 Jul 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

Votes

Translate

Translate
Community Expert ,
Jul 30, 2019 Jul 30, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 30, 2019 Jul 30, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines