4 Replies Latest reply on Jun 18, 2018 4:01 AM by user5108636

    Modal dialog page close button

    user5108636

      Hi All,

          Using APEX 5.1.3 with universal theme. I have a modal dialog page with a default close button on top right corner. I need to clear the cache for this modal page or clear two fields in the modal page  whenever the user clicks the close button on the top.

       

      Currently when the user closes the modal page and again opens it remembers value in the session for that page.

       

      Firstly I could not find the close button in the APEX IDE layout. Wonder if it defined in one of those templates and how can I add logic for one modal page to have close button event to clear cache or clear two fields in that page.

       

      Please advise.

        • 1. Re: Modal dialog page close button
          Neil Clare

          You could 'cheat' and configure the link to clear the cache when you open the page.

          • 2. Re: Modal dialog page close button
            user5108636

            No, each time the modal page is opened, new session values should be reflected. I created a cancel button on the same modal page which does that.

             

            Issue is want to replicate the logic for the default close button, same as the cancel button.

            Cannot find that default close button in the APEX IDE to begin with.

             

            Yet to figure out where to put the logic for the default close without breaking something else.

            • 3. Re: Modal dialog page close button
              fac586

              user5108636 wrote:

               

              No, each time the modal page is opened, new session values should be reflected. I created a cancel button on the same modal page which does that.

               

              Issue is want to replicate the logic for the default close button, same as the cancel button.

              Cannot find that default close button in the APEX IDE to begin with.

               

              Yet to figure out where to put the logic for the default close without breaking something else.

              See how to trigger DA when user clicks a standard close window button

               

              However, rethinking the application logic to avoid the need to resort to undocumented APIs is the recommended option.

              • 4. Re: Modal dialog page close button
                user5108636

                Hi Fac,

                      I have gone with the suggestion above and could see the console log "A dialog page closed" So basically the solution works.

                 

                 

                1) In my modal dialog page, I create a custom event named 'Dialog Exit'. Then put 'Custom Event' as 'dialogclose'. Selection Type as 'jQuery Selector'. 'jquery Selector' property as 'body'. Event scope dynamic.

                2) In the action Execute javascript code put below code

                 

                apex.util.getTopApex().jQuery("body")
                  .off("dialogclose.myHandlers")
                  .on("dialogclose.myHandlers", ".ui-dialog--apex", function(event) {
                  console.log("A dialog page closed");

                  apex.item(P40_ITEM1).setValue(null); 

                   apex.item(P40_ITEM2).setValue(null);
                  apex.util.getTopApex().jQuery("body").off("dialogclose.myHandlers");
                  });

                 

                How do I reset the session state for the modal page 40. Please advise, I tried setting individual page items to null but fails.