6 Replies Latest reply: May 2, 2014 10:01 AM by Tom Petrus RSS

    before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear

    KarenH

      I have an apex 4.2 page (P110) that contains an item called P110_VESSEL_ID.  It is a select list.    It has a post element text of:

      <a> id-"popVessels" href="#" style="color:blue">Select from ALL Vessels</a>

       

       

      when I select the link Select from ALL Vessels a dynamic action is initiated call Show Vessel LIst

      event: Click

      selection type: jQuery Selector

      jQuery Selector: #popVessels

       

      true action:  skillbuilders modal page 2

      static URL:   f?p&APP_ID.:114....

       

       

      this all works beautifully.

       

      A popup window (page 114) appears with a list of vessels (interative report region).   This report has an item VESSEL_ID defined as &nbsp.  It has a URL Link:

      javascript:window.parent.$(window.parent.document).apex_model_page('close',#VESSEL_ID#);

       

      when I click on the link for VESSEL_ID it closes the window and the value for P110_VESSEL_ID is populated with the value of #VESSEL_ID# from P114 exactly as intended.

       

      the issue I have now, is that if P114 #VESSEL_ID# is equal to 99999 then I would like an alert to popup telling the user that selecting this vessel may violate federal rule.

       

       

      any ideas?   and if you could explain any javascript I would appreciate it as I am very new to it.

       

       

      thanks, Karen

        • 1. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
          Tom Petrus

          Easiest way: define a function on the modal page

          function closeMe (pVessel){
            if ( pVessel !== "99999" || ( pVessel === "99999" && confirm ( "selecting this vessel may violate federal rule. Proceed?" ) ) ) {
              // vessel is not 999999
              // OR vessel is 99999 AND user wants to proceed
              window.parent.$(window.parent.document).apex_model_page('close', pVessel);   
            };
          };
          

          Now call this function in your link instead of directly calling the close:

          javascript:closeMe("#VESSEL_ID#");

          • 2. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
            KarenH

            HI Tom,

             

            thank you so much for your response.  It makes perfect sense!   Of course, now I need to complicate it.   The interactive report query includes VESSEL_ID and SUPPLIER_VESSEL_ID.   It is the VESSEL_ID which is passed back to P110, but it is the #SUPPLIER_VESSEL_ID# which will contain the 999999.

             

            I have modified the function:

             

            <script language="JavaScript">

             

            function closeMe(pVessel,psupplierVesselId){

             

                if (psupplierVesselId !=="999999"||(psupplierVesselId==="999999" && confirm("selecting this vessel may violate federal rul.  Proceed?"))) {

                   //vessel is not 999999

                   //OR vessel is 999999 and user wants to proceed

             

                  window.parent.$(window.parent.document).apex_model_page('close',pVessel);

                };

              };

             

            </script>

             

             

            #VESSEL_ID# has url:

             

            javascript:closeMe("#VESSEL_ID#","#SUPPLIER_VESSEL_ID#");

             

             

            Unfortunately, nothing happens...either for UNKNOWN vessel or any other vessel.  I am certain it is a syntax, but not clear where. 

             

            I also wanted to add one more condition, that this warning should only popup if the global variable G_ISSUING_AGENCY = '0016', otherwise, it is fine to select UNKNOW.

             

             

            thanks again!  this is really helpful.

             

            Karen

             

            
            
            
            
            • 3. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
              KarenH

              ok.  I think I may partially have the solution.

               

               

              the URL should have single quotes, not double.   and instead of if psupplierVesselId === 999999 in function, I use psupplierVesselId ==

               

              javascript: closeMe('#VESSEL_ID#','#SUPPLIER_VESSEL_ID#';

               

              now, the message does appear when SUPPLIER_VESSEL_ID appears, however, nothing happens when I select OK or CANCEL.

               

              if I select a vessel other than UNKNOWN, nothing appears....so the window does not close and does not pass the value of P114_VESSEL_ID to P110_VESSEL_ID.   But I am getting closer....now just need to tie in the condition for G_ISSUING_AGENCY.

               

              any help appreciated!

               

              "REMINDER FOR FEDERAL DEALERS:

               

              When reporting a product (e.g.worms, periwinkles, clams, oysters, etc) harvested from a shoreline, tidal flat, dock or other non floating platform, please ensure that NO VESSEL is checked (which will indicate FROM SHORE) instead of UNKNOWN vessel selection."

               

              btw, I just added the above actual message, is there a way to add formatting....bold, different foreground/background color?

               

              Message was edited by: KarenH

              • 4. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
                Tom Petrus

                Hi Karen,

                 

                Had a day off yesterday and didn't really check in on the forum

                 

                - The quotes shouldn't matter as far as javascript is concerned- a string is a string, double or single quotes. A string is passed in to the function, and the value is checked as such with triple equals (no type coercion as with double equals).

                - It's not totally clear to me how you have set up the url: is this in column link attributes or in your query?

                - It may help a lot to simply add an alert at the start of the function to see what is passed in, or a console.log call. Also to check if you're really getting into the IF structure.

                - is G_ISSUING_AGENCY a javascript variable, a page item or an application item?

                - as for the message: you can store the message in a page item, so you can alter it without going into javascript. As for formatting though: it's just a built in confirm. If you want markup and such you will need to use a jQuery dialog instead of the native confirm functionality.

                • 5. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
                  KarenH

                  Hi Tom,

                   

                  Perfect to take a day off mid-week!   and one should never check the forum while taking a day off!!

                   

                   

                  so....ugh, the reason the pop-up would not close and passback the value of #VESSEL_ID# is because (gulp), I am a horrible speller, and I misspelled modEl.   It should be modAl.   grrr.

                   

                   

                  as for G_ISSUING_AGENCY, it may be moot as now other agencies (aside from Feds) would like to implement the message.

                   

                   

                  thanks again for your help!  I really appreciated it and have a tiny bit more confidence in using javascript functions....though clearly not in spelling.

                   

                   

                  Karen

                  • 6. Re: before a modal pop-up window closed (w/skillbuilder) can a pop-up message appear
                    Tom Petrus

                    This happens At least now you'll always double-check "modal"