3 Replies Latest reply on Oct 19, 2011 12:51 PM by James Morley-Smith

    RHO DecodeEvent Not Working with JS Closures

      I'm unable to get doScan() to fire when I point the decodeEvent to a method in my application closure.

       

      Here is a test that you can use (place in the head of your doc):

       

       

          <script src="/js/jquery-1.6.4.min.js"></script>
          
          <script>  
          window.MYAPP = {
              init: function()
              {
                  scanner.start();
              },
              
              doScan: function(json)
              {
                  alert(json.data);
              }
          };
          
          $(document).ready(function() {
              MYAPP.init();
          }); 
          </script>
              
          <!--RhoElements Tags-->
          <meta http-equiv="scanner" content="aimType:presentation">
          <meta http-equiv="scanner" content="enable">
          <meta http-equiv="scanner" Content="DecodeEvent:url('javascript:window.MYAPP.doScan(%json);')">
      


      Am I doing something wrong here? How can I get doScan to fire?

        • Re: RHO DecodeEvent Not Working with JS Closures
          Robert Galvin

          Joshua

           

          Unfortunately we do not currently support closures when you reference a function for our javascript objects. You would have to pull it out into a standard function.

           

          Connected by DROID on Verizon Wireless

          1 of 1 people found this helpful
            • Re: RHO DecodeEvent Not Working with JS Closures

              Gotcha. In case anyone wants to know a workaround, I was able to solve this issue by adding a global doScan that delegates the scan data to my closure.

               

                  <script>  
                  window.MYAPP = {
                      init: function()
                      {
                          scanner.start();
                      },
                      
                      doScan: function(json)
                      {
                          alert(json.data);
                      }
                  };
                  
                  function doScan(json)
                  {
                      MYAPP.doScan(json);
                  }
                  
                  $(document).ready(function() {
                      MYAPP.init();
                  }); 
                  </script>
              
              
                      
                  <!--RhoElements Tags-->
                  <meta http-equiv="scanner" content="aimType:presentation">
                  <meta http-equiv="scanner" content="enable">
                  <meta http-equiv="scanner" Content="DecodeEvent:url('javascript:doScan(%json);')">