1 2 Previous Next 27 Replies Latest reply: Apr 1, 2014 2:17 PM by TexasApexDeveloper RSS

    Dynamic Action jQuery Selector Problem

    Becky

      Hello,

       

      I am running ApEx version 4.1.1 on Oracle 10.2.0.4.0 on Linux.

       

      I am trying to mimic what is in Denes Kubicek application https://apex.oracle.com/pls/otn/f?p=31517:315:1:

      for jQuery Cascading LOV Tabular.

       

      In the tabular form the first LOV (called Type) is "f05".

       

      I created a dynamic action:

      Event: Change

      Selection Type: jQuery Selector

      jQuery Selector: select[name="f05"]

       

      The first true action is an Alert which is set to fire on page load and simply says "In Dynamic Action".

       

      When I hit the Add button a blank record appears as expected.

      When I select a Type in the Type LOV the Dynamic Action is not firing.

      Thinking I was using the wrong column in the Tabular form, I changed the jQuery Selector to "fxx" up to the max number of my columns and nothing worked.

      I checked in Firefox and it is not firing.  What am I doing wrong?

       

      Thanks so much,

      Becky

        • 1. Re: Dynamic Action jQuery Selector Problem
          Tom Petrus

          Have you tried to run your selector in the browser's console (eg firebug)? Is your region perhaps being refreshed? Is the scope of the action set to static or dynamic?

          • 2. Re: Dynamic Action jQuery Selector Problem
            Becky

            Tom,

             

            I have used Firefox's debugger.  I can see other DAs firing but not this one.

             

            I don't know of anything that would cause the region to refresh.

             

            I don't know what your last question means:

            Is the scope of the action set to static or dynamic?

             

            Thanks,

            Becky

            • 3. Re: Dynamic Action jQuery Selector Problem
              Tom Petrus

              Sorry, in apex 4.1 the scope is the bind type of the dynamic action, "Live" or "Bind". If I'm not mistaken it is under the advanced part of the DA (not true/false action).

               

              When your page has finished loading, have you tried to run your selector from the console: $(select[name="f05"]) and if yes, this does return elements?

              • 4. Re: Dynamic Action jQuery Selector Problem
                Becky

                Tom,

                 

                The bind type is "Bind".

                 

                Interesting fact:  In Firefox, the following errors do not occur, only in IE:

                IE throws error "Object doesn't support this property or method" which is (function(){apex.da.initDaEventList();})();

                IE is also throwing an error in the Dynamic Query:

                var elem = '#' + this.triggeringElement.id;

                var key = '#' + 'f02_' + this.triggeringElement.id.substring(4);

                var set_list = '#' + 'f04_' + this.triggeringElement.id.substring(4);

                 

                 

                var key_val = $(key).val();

                var elem_val = $(elem).val();

                 

                var selected_val = '';

                 

                apex.server.process (

                    "getEmployees",

                    {

                      x01: elem_val,

                      x02: key_val

                    },

                    {

                      success: function( pData ) {

                 

                      $(set_list).find('option').remove();

                 

                      $.each(pData, function(key, innerjson) {

                      $(set_list).append($('<option>', {

                      value: innerjson.VALUE,

                       text: innerjson.NAME

                        }))

                      if (innerjson.SELECTED != '') {selected_val = innerjson.SELECTED};

                      });

                 

                      if (selected_val != '') {

                        $('select' + set_list + ' option').each(function()

                        {this.selected = (this.text == selected_val);});

                      }

                       },

                    }         <--------- HERE

                );

                 

                How do you run the selector from the console: $(select[name="f05"])?  All I have is the Firefox debugger. Firebug stopped working last week.

                • 5. Re: Dynamic Action jQuery Selector Problem
                  Becky

                  Tom,

                   

                  I was just informed the Firefox debugger IS the new Firebug!!  So I did figure out how to run the selector from the console:  I received the following:  ReferenceError: select is not defined.

                  • 6. Re: Dynamic Action jQuery Selector Problem
                    Becky

                    In doing more research I believe the apex.server.process and associated select are in 4.2 and not in 4.1.  Is there a work around?

                    • 7. Re: Dynamic Action jQuery Selector Problem
                      Aljaz

                      Hi,

                       

                      you can use htmldb_Get

                       

                      Regards,

                        Aljaz

                      • 8. Re: Dynamic Action jQuery Selector Problem
                        Tom Petrus

                        with  $(select[name="f05"]) I actually meant $('select[name="f05"]') - sorry, forgot the quotes there.


                        And yes, apex.server.process is new in apex 4.2 and not in 4.1. You could use htmldb_Get, yes. But why not use $.ajax until you get to 4.2. This can only be a good thing since apex.server.process wraps $.ajax, and can take the same options and also returns the same object. You'll have a good headstart on it by using proper ajax calls.

                        Eg:

                        var ajaxData = {  "p_request"      : "APPLICATION_PROCESS=getEmployees"

                                        , "p_flow_id"      : $v('pFlowId')

                                        , "p_flow_step_id" : $v('pFlowStepId')

                                        , "p_instance"     : $v('pInstance')

                                        , "x01"            : elem_val

                                        , "x02"            : key_val

                                       };

                        $.ajax( 

                               {  "url"      : 'wwv_flow.show'  //URL request is sent to

                                , "type"     :"POST"            //type of ajax request. GET,POST,...

                                , "dataType" :"text json"       //how jquery will parse the return value. Default in 4.2 JSON

                                , "data"     : ajaxData         //object with data to be sent which will be converted to a query string

                                , "success"  : function(pData){

                                    //handle the successful return -> pData

                                 }

                               }

                              );

                         

                        All info on $.ajax: jQuery.ajax() | jQuery API Documentation

                        • 9. Re: Dynamic Action jQuery Selector Problem
                          Becky

                          Tom,

                           

                          I realized these errors are caused by missing APIs in version 4.1.1.  The specific APIs are "apex.server.process" and "apex.da.initDaEventList()".  Is there a possible workaround?

                          • 10. Re: Dynamic Action jQuery Selector Problem
                            Tom Petrus

                            Yes, for apex.server.process, use $.ajax (jQuery) (see above, my previous post) or the old, undocumented htlmdb_get. apex.da.initDaEventList() is not a problem, it just errors out because it initializes the dynamic actions. If one contains an error, then you're likely to see an error on that line. (You're not even calling it directly)

                            • 11. Re: Dynamic Action jQuery Selector Problem
                              Becky

                              Hi Tom,

                               

                              I didn't think I had posted the "work around" request!!  Thanks so much.  I will try it out!

                               

                              Becky

                              • 12. Re: Dynamic Action jQuery Selector Problem
                                Becky

                                Tom,

                                 

                                Will I try out the new code.  In the meantime, I still cannot get the DA running.  I entered $('select[name="f05"]' as you suggested.  I get [object Object] which in looking at it, it does contain the Type list.  The DA is just not firing!

                                • 13. Re: Dynamic Action jQuery Selector Problem
                                  Tom Petrus

                                  Becky,

                                   

                                  The selector will probably work fine, but as long as there is invalid javascript code in there, you might run into problems. If you want to make sure, try only using an alert on change.

                                  • 14. Re: Dynamic Action jQuery Selector Problem
                                    Becky

                                    Thanks Tom.  I did just that and it still doesn't work.  I have since upgraded ApEx to 4.2.4!!  Hopefully that may shed some light on the subject!

                                     

                                    Becky

                                    1 2 Previous Next