开发者

Scripty2 : how to close dialog

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开发者_Go百科) 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.


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


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


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();});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜