Caja / Apps Scripts jQuery $(document).ready not firing

507 Views Asked by At

I have a project in Apps Scripts where the code in my $(document).ready never gets executed. I also tried with this basic code at http://caja.appspot.com/, which also doesn't work.

<html>
  <head>
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>
    $( document ).ready(function() {
      $("span").text("Working");
    });
    </script>
  </head>
  <body>
   <span>Not Working</span>
  </body>
</html>​

The "Not Working" text shows up. Also tried with jQuery versions 2.x.x

Any ideas?

Thanks

1

There are 1 best solutions below

1
Cameron Roberts On

This works if you use a slightly older jQuery version.

<html>
  <head>
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
      $("span").text("Working");
    });
    </script>
  </head>
  <body>
   <span>Not Working</span>
  </body>
</html>

I'm not sure why, since the documentation says Caja works with all recent jQuery versions: https://developers.google.com/apps-script/guides/html/restrictions#jquery_and_jquery_ui