Loading Google visualization before jQuery

I am having problems with the DOM, because before jQuery, elements were loaded inside google visualization tables / graphs. So I realized that I need to load google visualization before jQuery.ready () ..

Google visualization is downloaded using:

google.load("visualization", "1", {packages:["linechart","table","piechart"]});
google.setOnLoadCallback(drawGraph);

How can I make sure that Google visualizaion is loaded before running the .ready () function?

Thanks Joel

+3
source share
1 answer

You can define document.readyinside the function, and it will work when called if it is already ready, for example:

google.load("visualization", "1", {packages:["linechart","table","piechart"]});
google.setOnLoadCallback(myLoad);

function myLoad() {
  drawGraph();
  $(document).ready(function() {
   //Stuff here
  });
}

It should be noted here that you may not need document.ready at all, you can simply paste the contents into the same function.

drawGraph(); .ready().

+3

Source: https://habr.com/ru/post/1735743/


All Articles