Get all dialogs listed

Get all dialogs listed

Hi,
I was wondering is there a way to get all dialogs and close/open them with a button that has .live("click") set to it?

Tried using this
  1. $("button").live("click",function(){
  2.       $("div.ui-dialog").dialog("close");
  3. });
but it didn't work.

Edit

Got it working, here is the code (if someone want's it)

  1. $('button').live('click', function(){
  2.       $("div.ui-dialog").each(function(){
  3.             var id = $(this).attr("aria-labelledby").replace('ui-dialog-title-','');
  4.             $("#"+id).dialog("close");
  5.       });
  6.       return false;
  7. });