Skip to main content
Inspiring
November 14, 2014
Answered

Why does closing a window in Indesign doesn't work?

  • November 14, 2014
  • 1 reply
  • 744 views

I have a question concerning Indesign script.

Why does it work, when you close a window like:

submitButton.onClick = function(){ close(); }

But when I try to execute a function afterwards like:

submitButton.onClick = function(){ close(); tagElements(); }

(note I am using the "with" tag, so no window.close() is needed)

The window does not close? Am I forgetting about something here? Shouldn't the window close, and then execute the function?

The window is initialized like:

var de = new Window('dialog', 'Descriptions');
This topic has been closed for replies.
Correct answer Harbs.

Yep this is a difference between the way CS and CC handle dialog modules.

CS does what you want and CC does not.

This is not the only example you can find of this

You can the function as an object to pass data i.e. instead of var de = .... you could use newwindow.de = .... this can sometimes have advantages over globals, for example keeping track of the variables origin and the ability to delete it.

You could of course use palettes or windows instead of dialogs with those you do not have this problem.

Maybe someone else has some better ideas.


Here's the pattern I use:

  var ds = new Window('dialog');

   buttonnew = ds.add('button', undefined, 'submit');

   buttonnew.onClick = function(){

       ds.close(1);

   }

if(ds.show()){

  newwindow();

}

   function newwindow(){

   var de = new Window('dialog');

   buttonnew2 = de.add('button', undefined, 'submit');

   buttonnew2.onClick = function(){

       de.close(1);

   }

   if(de.show()){

     dosth();

}

}

function dosth(){

       alert('test');

   }

1 reply

Trevor:
Legend
November 17, 2014

Stamm wrote:

(note I am using the "with" tag, so no window.close() is needed)

The window is initialized like:

var de = new Window('dialog', 'Descriptions');

O.k. but did you see if it does work when you use de.close() ?

StammAuthor
Inspiring
November 17, 2014

Hey, sadly doesn't work. I've put the "close" tag outside of the "with" function now and it's still the same error.

Trevor:
Legend
November 17, 2014

Try minimizing the script (ON A BACKUP) to the point where you no longer get the problem or you still get the problem and then post the script here