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

Cannot handle the request because a modal dialog or alert is active

Guest
Oct 12, 2009 Oct 12, 2009

Copy link to clipboard

Copied

I'm getting this error in a script, and can't figure out why.  Earlier in the script, I open a dialog and then close it before I begin processing.  The error occurs in processing when I try to set the CellStyle on some cells in a table.

I get the message in debug mode, so it could be complaining about the debug window.  In non-debug mode, my script runs through but no styles are changed.

Anybody got any ideas?

Code except:

        var currentLine = myFirst;
        while (currentLine<myLast) {
            var lineOffset = currentLine - myFirst;
            with (myTable.rows.[currentLine])  {
                if (myCellStyle != null && myCellStyle.text != '')  {
                    cells.everyItem().appliedCellStyle = myCellStyle.text;
               }
            }
            currentLine++;
        }

Full script attached

TOPICS
Scripting

Views

3.6K

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

Guide , Oct 12, 2009 Oct 12, 2009

Hi LeeShort,

The answer is in the question. A scriptUI modal dialog can't interact with UI DOM object until you close the dialog.

In your script, you call ProcessTable() from BtnOK.onClick event. When this event occurs, the dialog window is not yet closed.

In fact, you don't need the two lines:

win.GrpCancelOK.BtnOK.onClick = function () { this.parent.parent.close(1); ProcessTable();};
win.GrpCancelOK.BtnCancel.onClick = function () { this.parent.parent.close(1); };

because by default the window hid

...

Votes

Translate

Translate
Guide ,
Oct 12, 2009 Oct 12, 2009

Copy link to clipboard

Copied

Hi LeeShort,

The answer is in the question. A scriptUI modal dialog can't interact with UI DOM object until you close the dialog.

In your script, you call ProcessTable() from BtnOK.onClick event. When this event occurs, the dialog window is not yet closed.

In fact, you don't need the two lines:

win.GrpCancelOK.BtnOK.onClick = function () { this.parent.parent.close(1); ProcessTable();};
win.GrpCancelOK.BtnCancel.onClick = function () { this.parent.parent.close(1); };

because by default the window hides itself on OK / Cancel.

So, use rather the value returned by the win.show() method (1 for OK, 2 for Cancel) and try something like this:

if (win.show() == 1) // OK
     {
     ProcessTable();
     }

else

     { // Cancel

     }

By the way, the body of ProcessTable() contains an undefined selection variable. Do you mean app.selection?

@+

Marc

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
Guest
Oct 12, 2009 Oct 12, 2009

Copy link to clipboard

Copied

Thanks for the thorough answer.  That did the trick!

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
Explorer ,
Sep 15, 2011 Sep 15, 2011

Copy link to clipboard

Copied

I know this is an old post but I'm hoping someone is still around to look at this. I have almost the same problem and I'm not sure how what you suggested fixed the problem. Here is my code for an onchange event on a pull down. Right now all I am trying to accomplish is placing an asset on the page when the pull down changes but I get the "Cannot handle the request because a modal dialog or alert is active" probably because the window that this pull down is still open even though I attempt to close it before interacting with the document. Any suggestions?

myEventPulldown.onChange = function ()

{

myDialog.close();

var myLibs = app.libraries;

var myLib = myLibs.item("testLibrary.indl");

var myAssets = myLib.assets;

var theAsset = myAssets[0];

try

{

theAsset.placeAsset(app.activeDocument);

}

catch(e)

{

alert(e);

}

}

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
LEGEND ,
Sep 15, 2011 Sep 15, 2011

Copy link to clipboard

Copied

You have to move your code out of the onChange function.

Set some variable that you read when the dialog is closed to know what to do...

Harbs

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
Explorer ,
Sep 16, 2011 Sep 16, 2011

Copy link to clipboard

Copied

LATEST

Wish I could give you some points for the correct answer! I hope a thank you will do.

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