Skip to main content

I asked this the other day and Zack wrote a snippet for closing 1 popup. Now I need to close 2.
I tried modifying the snippet, but can’t get it to work
 close_popup = function(){         var popup_array = skuid.$(‘.ui-dialog-content’);
         for (i = 0; i < popup_array.length; i++){
        popup_array i].dialog(‘destroy’);
        popup_array    };
i do get the array, which appears to have dom elements in it, but i get “undefined is not a function” when i try and call destroy
do i have to somehow transform the array item into something jquery can call ‘dialog’ on ?

This will close, destroy, and remove all open popups on the screen:

skuid.$(‘.ui-dialog-content’).dialog(‘close’);


Thanks Zach,
I was  trying to hard, I guess.
Ken


Is there an easy way to have it close the window as well?


window.close();

https://developer.mozilla.org/en-US/docs/Web/API/Window/close


#mustlearnjavascript

#Ihatedumbquestions


Is there a way to close two out of three popups on a page?

I tried this but it didn’t work:


var pop1 = skuid.$('.ui-dialog-content')'1]; var pop2 = skuid.$('.ui-dialog-content')'2];<br>pop1.dialog('close');<br>pop2.dialog('close');&nbsp;

Figured out a solutions. Not sure if its the best way:

https://api.jqueryui.com/dialog/ helped a lot.


$.each(skuid.$('.ui-dialog-content'), function(i, row){&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; if(i==2 || i==1){<br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; var UIiD = "#"+this.id;<br>&nbsp; &nbsp; &nbsp; &nbsp; skuid.$(UIiD).dialog('close');<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp;&nbsp;<br>});