Alpha Video Training
Results 1 to 21 of 21

Thread: Closing popups

  1. #1
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,620

    Default Closing popups

    Is anyone else spending inordinate amounts of time trying to get popups to close? I know about a half dozen ways to do it, yet often (including the last two days) just cannot get 'em to close.

    Some methods I know about/have tried include:

    - Setting the calling method to close the window after submit
    - Declaring the window[] name in the UX OnInitializeComplete and close that
    - Inserting a <div> to the UX window title and hiding that
    - using {dialog.Object}.closeContainerWindow(this);
    and a few other less-common methods

    One current example is a popup UX where I try {dialog.Object}.closeContainerWindow(this). I've tried it in several locations/methods/implementations by the way. The Chrome console tells me:

    Uncaught TypeError: Object function (obj){if(obj.responseText)eval(obj.responseText);} has no method 'getAttribute' a5-19704257.js:547
    A5.windows.getFromElement a5-19704257.js:547
    A5.DialogComponentHelper.closeContainerWindow a5-19704257.js:11429
    (anonymous function) VM2927:6
    $a._rh._eval a5-19704257.js:242
    (anonymous function)
    I'm spending enough time on this to cast a net to see what I can learn -- I have to be missing something because the problem just so pervasive in my current project.
    -Steve


  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,764

    Default Re: Closing popups

    Hey Steve,

    There are about a billion (yes... a billion) ways to work with 'popups'. Right now I can only think of 4, but it feels like a billion. Could you put together a really simple example of a popup not closing? Then focus can go to exactly the problem instead of going off on some tangent that proposes a solution which doesn't apply.

  3. #3
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Closing popups

    I am having the same issue as Steve can anyone shed a light on this problem?
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  4. #4
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,620

    Default Re: Closing popups

    I've worked through many of them - often with Andy Meer's help but they can be downright stubborn. A couple of them I've just told my customer they're going to have to click the Close button when done.
    -Steve


  5. #5
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Closing popups

    I have burned up about 2 hours trying the examples to get a popup window ux to close. Not too much trouble if the popup is a grid. I can get the ID of the <div> object like this and hide it but then I cannot reopen.
    Code:
    //var wObj = $("A5dlg3");
    //wObj.hidden = 'true';
    I tried these everywhere and no success.
    Code:
    {dialog.Object}.closeWindow('WNDGETSIGNATURE');
    dialog.Object}.closeContainerWindow(this); (this throws an error in firefox)
    var ele = $('WNDGETSIGNATURE'); 
    dialog.Object}.closeContainerWindow(ele);
    I have decided to try opening my ux in a dynamic panel. Any ideas on how to programmatically close a dynamic panel?
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  6. #6
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,620

    Default Re: Closing popups

    I took to a similar solution in recent days. My current development app doesn't use panels, but I built a UX with conditional containers and find I can manage that pretty well. With a bit of design consideration to "fit" into the project, I'm probably going to do more of this rather than deal with uncloseable popups.
    -Steve


  7. #7
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Closing popups

    Video D 50 shows another method to open pop ups that can be easily closed. I will have to rethink things a bit.
    Actually video UX 54 clears it all up. The examples and help dialogs are missing some key commands.
    Last edited by frankbicknell; 03-17-2014 at 08:26 PM.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  8. #8
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,620

    Default Re: Closing popups

    I've seen Selwyn's videos using that method before, but never used it even though I thought it quite clever. I'll take to using/trying that in the future as well, see if it helps save some time. Thanks for finding and pointing that out.
    -Steve


  9. #9
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Closing popups

    I don't know how getting the id of a button then using that id in the closeContainerWindow method works.... but it does.

    OK I see why this works now because
    this works in a button.
    Code:
    {dialog.Object}.closeContainerWindow(this);
    I guess you could get a pointer to any component in the window. Maybe only buttons.
    Last edited by frankbicknell; 03-18-2014 at 08:40 AM.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  10. #10
    "Certified" Alphaholic
    Real Name
    Rich Fulham
    Join Date
    May 2011
    Location
    Portland, OR
    Posts
    1,021

    Default Re: Closing popups

    From other threads on this topic:

    To close a popup grid component there is:

    {grid.object}.closeParentContainer();

    The trick is calling it at the right time and place. Wrap it in a function declared in the component's global js functions like this to ensure "{grid.object}" placeholder is properly replaced:

    function ClosePopupXXX() { {grid.object}.closeParentContainer(); }


    Call the function after a successful record insert/update/delete ajax call, by adding it to the javascript response code for server-side events "AfterUpdateRecord", "AfterInsertRecord", "AfterDeleteRecord":

    aa = e.rtc.A_AjaxResponses
    aa[].text = RefreshParentXXX(e) // add your own js function to update controls in parent record with changed data
    aa[..].id = 100

    aa[].text = "setTimeout('ClosePopupXXX ();', 20);" // slight delay of '10' or '20' ms to give above code time to execute before actually closing window.
    aa[..].id = 101

    NOTES:
    - I define a "RefreshParentXXX" JS function to update controls in the parent window with changed data from the popup, omit if not needed.
    - I've only tested / used this in the "AfterUpdateRecord" event.
    - I had to add this because my popup grid component has a hidden grid and only uses an "OnPage" detail view. The "Close detail view after submit" property isn't any use in this situation because it doesn't know it should also close the hidden grid (entire popup) after a submit.

  11. #11
    Member
    Real Name
    Jenny Gong
    Join Date
    Jul 2013
    Posts
    282

    Default Re: Closing popups

    I have the same issue. in UX, i have a button, once i click it, it will run ajax callback, at the end of xbasic function, i put functionname="{dialog.Object}.closeContainerWindow(this);"
    it is not wokring, and get error message....Anyone can help me?

  12. #12
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Re: Closing popups

    Quote Originally Posted by jennygong View Post
    I have the same issue. in UX, i have a button, once i click it, it will run ajax callback, at the end of xbasic function, i put functionname="{dialog.Object}.closeContainerWindow(this);"
    it is not wokring, and get error message....Anyone can help me?
    If I read your problem correctly you placed a javascript function in your xbasic code ... I don't believe you can do this. Try making another javascript action for your button (inline javascript). Makes sure you run the actions synchronously.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  13. #13
    Member
    Real Name
    Jenny Gong
    Join Date
    Jul 2013
    Posts
    282

    Default Re: Closing popups

    Quote Originally Posted by mikeallenbrown View Post
    If I read your problem correctly you placed a javascript function in your xbasic code ... I don't believe you can do this. Try making another javascript action for your button (inline javascript). Makes sure you run the actions synchronously.

    This method usually works in grid component. If using your way, i could not find javascipt action insert button in UX component.

  14. #14
    Member
    Real Name
    Robert V.
    Join Date
    Jan 2014
    Posts
    30

    Default Re: Closing popups

    relying on 'this' to get a pointer to the dialog to close the window seems to be unreliable, particularly after a callback.

    try picking the ID of a component on the dialog (any button, it doesn't matter which one) and use that to get a pointer to the dialog window:

    // close window
    var ele = {dialog.Object}.getPointer('BUTTON_SUBMIT');
    {dialog.Object}.closeContainerWindow(ele);

  15. #15
    Member mixter's Avatar
    Real Name
    Michael Merlin
    Join Date
    Sep 2011
    Location
    Melbourne, Australia
    Posts
    220

    Default Re: Closing popups

    Both Mike Brown and Robert V have pointed the answer, thanks for that, sure helped me out!

    In my case, I have a UX popup window that I want to close as the Submit button is clicked (i.e. close the window after the record is saved)

    For the sake of clarity I've attached a screen shot for Jenny and others.

    ClosePopupUX_OnSubmit.png

    which shows, on the Submit button Click event

    create two inline Javascript

    and make sure "Run actions synchronously" is checked true

    + Add New Action
    -- Ajax Callbacks and Javascript
    ---- Inline-Javascript

    the code inside the first Inline-Javascript is

    {dialog.object}.submit();


    the code inside the second Inline-Javascript is

    var ele = {dialog.Object}.getPointer('BUTTON_SUBMIT');
    {dialog.Object}.closeContainerWindow(ele);



    This also requires that in your Server Side Events
    in "afterDialogValidate"
    you have the usual server side action script which saves the record

    i.e.

    ExecuteServerSideAction("Save Data::Save_Submitted_Data_to_Table_s_")

  16. #16
    Member
    Real Name
    Robert V.
    Join Date
    Jan 2014
    Posts
    30

    Default Re: Closing popups

    In the case of a submit button, I would avoid putting the close window JS directly in the client-site submit button click event, as I expect this is going to close the window whether the save is successful or not?

    I'm assuming you don't want to close the window if there is some sort of validation error, or the the submit is unsuccessful?

    Assuming you're using server-side AfterDialogValidate event to call action scripting save submitted data to tables, take a look at the editor for this action script and use the "After Save Succeeded Javascript". Use this to call your close window JS... something like:

    // close window
    var ele = {dialog.Object}.getPointer('BUTTON_SUBMIT');
    {dialog.Object}.closeContainerWindow(ele);

  17. #17
    Member mixter's Avatar
    Real Name
    Michael Merlin
    Join Date
    Sep 2011
    Location
    Melbourne, Australia
    Posts
    220

    Default Re: Closing popups

    Hi Robert,

    Thanks for the excellent tip, using the server side event, to generate javascript to send back to the client

    I'm reading all those comments in the server-side events more closely now!

    So what I have done is updated my client-side Submit button Click event, so it is now just one line again
    Code:
    {dialog.object}.submit();
    And as you suggested, I've edited server-side AfterDialogValidate event

    I am now also using a server side test of the value for
    rtc.flagRecordWasSaved

    Code:
    ExecuteServerSideAction("Save Data::Save_Submitted_Data_to_Table_s_")
    
    if rtc.flagRecordWasSaved then
    	e.javascript = e.javascript + crlf() + "alert('Data was saved');"
    	e.javascript = e.javascript + crlf() + "var ele = {dialog.Object}.getPointer('BUTTON_SUBMIT');"
    	e.javascript = e.javascript + crlf() + "{dialog.Object}.closeContainerWindow(ele);"
    else
    	e.javascript = e.javascript + crlf() + "alert('Did not save, please click the Save Data button once again!');"
    end if
    the alerts proved that rtc.flagRecordWasSaved is working as expected.

    I took my SQL Server offline while I was mid-edit in the browser popup window, and got the second alert when clicking the Submit button

    Then I bought my SQL Server back online again, and the data saved successfully when clicking Submit

    cool

  18. #18
    Member
    Real Name
    Robert V.
    Join Date
    Jan 2014
    Posts
    30

    Default Re: Closing popups

    also, check out the spot in the action script editor "After save succeeded Javascript". Put your JS here, and you don't have to even test if the save worked.

    shot.png

  19. #19
    Member mixter's Avatar
    Real Name
    Michael Merlin
    Join Date
    Sep 2011
    Location
    Melbourne, Australia
    Posts
    220

    Default Re: Closing popups

    Robert, that's excellent!

    I did go looking for "After save succeeded Javascript" but I didn't find it the first time because I was looking in the wrong place.

    With that screen capture I now see exactly what you meant.

    That way you indicated is much nicer, entering the javascript directly into that client side event property

    instead of how I was doing it, adding it inside the xbasic e.javascript string

    e.javascript = e.javascript + crlf() + ...javascript...


    Also saves xbasic coding by not having to check the rtc.flagRecordWasSaved value

    Thank you for sharing your knowledge!

  20. #20
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Closing popups

    If you are opening the UX from a button or hyperlink from a Grid or UX, you can uncheck this option in the Action Javascript.
    Attached Images Attached Images
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  21. #21
    Member compuaid's Avatar
    Real Name
    Brad Weaver
    Join Date
    Aug 2007
    Location
    Ottawa, ON
    Posts
    384

    Default Re: Closing popups

    Great thread! Thanks everyone for sharing the tips. Should save all of us a lot of headaches in the future.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

Similar Threads

  1. Triggering fields with popups to pop up
    By Jeff Fried in forum Alpha Five Version 7
    Replies: 19
    Last Post: 01-19-2007, 01:35 AM
  2. Help Popups should stay on screen
    By csda1 in forum Archived Wishlist
    Replies: 0
    Last Post: 09-19-2006, 06:15 PM
  3. Set Popups
    By Bill W.F. Greenberg in forum Alpha Four Versions 7 and 8
    Replies: 4
    Last Post: 01-29-2005, 08:59 AM
  4. Table Lookup Unwanted Popups
    By John Gamble in forum Alpha Five Version 5
    Replies: 13
    Last Post: 12-31-2002, 05:35 PM
  5. Popups and dialogs..grrrrr
    By tlyon in forum Alpha Five Version 4
    Replies: 3
    Last Post: 07-03-2000, 03:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •