views:

167

answers:

3

Heya,

I am looking for a way to close a scripty2 dialog like this : http://mir.aculo.us/stuff/scripty2-ui/test/functional/controls_dialog.html

From outside of the dialog (i.e. with firebug command line) but my javascript mojo is a bit limited and after 30 min of going around the DOM I cannot find a way. Any hints ?

NB : scripty2 is a rewrite of script.aculo.us which uses bits of Jquery UI.

A: 

This is the documentation for the dialog box : http://scripty2.com/doc/scripty2%20ui/s2/ui/dialog.html

nicolas_o
A: 

To close all the dialogs (elements with class div.ui-dialog) on the page with no ids code would be something like this (untested):

$$('div.ui-dialog').each(function() {this.close();});
markb
Thank you for the answer. It did not work.
nicolas_o
A: 

Scripty2 UI bits are really based on Prototype classes, not extensions to DOM elements, so you can't use $$() to fetch an existing dialog and close it like you might think. It must be stored in a javascript variable.

var dialog = new S2.UI.Dialog({ // The class must be saved in a 
variable 
  content: "Consulting the server. Please wait." 
}); 

dialog.open(); // We open 
new Ajax.Request('/answers', { 
  onComplete: function(){ 
    alert("Done!"); 
    dialog.close(); // And close. 
  } 
}); 

Try pasting these into Firebug:

var dialog = new S2.UI.Dialog({content: "Hello World"}); 
dialog.open(); 
dialog.close(); 
barry