jquery 和 google 表格可视化

发布于 2024-09-09 05:37:30 字数 2586 浏览 6 评论 0原文

我希望有人可以帮助我。我在同一页面上使用 google.code 可视化工具和 jquery。

我正在文档上调用 $(document).ready 函数,但怀疑问题在于调用 google.setOnLoadCallback(drawVisualization); 函数。

document.ready 函数之后仍然会加载,然后不会将灯箱效果应用到表格上有关

<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
    });
    </script>

如何在谷歌可视化表格加载后将灯箱效果应用到表格中的链接的任何想法?

我还添加了完整的脚本,因为我现在拥有它,这应该有助于查找问题。

    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['table']});
    </script>
<script type="text/javascript">
    function drawVisualization() {
      // Create and populate the data table.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'No');
      data.addColumn('string', 'Page URL');
      data.addColumn('string', 'EDIT');
      data.addRows(10);
      <% while ((Repeat1__numRows-- != 0) && (!rs_page_1.EOF)) { %>
      data.setCell(<%= Repeat1__index %>, 0, '<%=(rs_page_1.Fields.Item("g_page_no").Value)%>');
      data.setCell(<%= Repeat1__index %>, 1, '<a href="<%=(rs_page_1.Fields.Item("g_page_site").Value)%><%=(rs_page_1.Fields.Item("g_page_url").Value)%>"><%=(rs_page_1.Fields.Item("g_page_site").Value)%><%=(rs_page_1.Fields.Item("g_page_url").Value)%></a>');
      data.setCell(<%= Repeat1__index %>, 2, '<span class="gallery clearfix"><div class="btn_newsite"><a href="/application/functions/preview.asp?g_sites_no=<%=(rs_page_1.Fields.Item("g_sites_no").Value)%>&amp;g_page_no=<%=(rs_page_1.Fields.Item("g_page_no").Value)%>&amp;iframe=true&width=100%&height=100%" rel="prettyPhoto1[iframes]" title="View">Edit</a></div></span>');
      <%
  Repeat1__index++;
  rs_page_1.MoveNext();
};
%>
      // Create and draw the visualization.
      visualization = new google.visualization.Table(document.getElementById('table'));
      visualization.draw(data, {'allowHtml': 'true'}, {'showRowNumber': 'true'}, {'firstRowNumber': '1'});
    }
    google.setOnLoadCallback(drawVisualization);
    </script>
<div id="table"></div><script type="text/javascript" charset="utf-8">
        $(document).ready(function(){
            $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
        });
        </script>

谢谢

I am hoping that there is someone that can help me. I am using the google.code visualization tools and jquery on the same page.

I am calling the $(document).ready function on the document but suspect the problem lies with calling the google.setOnLoadCallback(drawVisualization); function.

Which still loads after the document.ready function and then does not apply the lightbox effect onto the table

<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
    });
    </script>

Any ideas on how to apply the lightbox effect to a link in the table, after the google visualization table has loaded?

I have also added the complete script as I have it now should this help in finding the problem.

    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['table']});
    </script>
<script type="text/javascript">
    function drawVisualization() {
      // Create and populate the data table.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'No');
      data.addColumn('string', 'Page URL');
      data.addColumn('string', 'EDIT');
      data.addRows(10);
      <% while ((Repeat1__numRows-- != 0) && (!rs_page_1.EOF)) { %>
      data.setCell(<%= Repeat1__index %>, 0, '<%=(rs_page_1.Fields.Item("g_page_no").Value)%>');
      data.setCell(<%= Repeat1__index %>, 1, '<a href="<%=(rs_page_1.Fields.Item("g_page_site").Value)%><%=(rs_page_1.Fields.Item("g_page_url").Value)%>"><%=(rs_page_1.Fields.Item("g_page_site").Value)%><%=(rs_page_1.Fields.Item("g_page_url").Value)%></a>');
      data.setCell(<%= Repeat1__index %>, 2, '<span class="gallery clearfix"><div class="btn_newsite"><a href="/application/functions/preview.asp?g_sites_no=<%=(rs_page_1.Fields.Item("g_sites_no").Value)%>&g_page_no=<%=(rs_page_1.Fields.Item("g_page_no").Value)%>&iframe=true&width=100%&height=100%" rel="prettyPhoto1[iframes]" title="View">Edit</a></div></span>');
      <%
  Repeat1__index++;
  rs_page_1.MoveNext();
};
%>
      // Create and draw the visualization.
      visualization = new google.visualization.Table(document.getElementById('table'));
      visualization.draw(data, {'allowHtml': 'true'}, {'showRowNumber': 'true'}, {'firstRowNumber': '1'});
    }
    google.setOnLoadCallback(drawVisualization);
    </script>
<div id="table"></div><script type="text/javascript" charset="utf-8">
        $(document).ready(function(){
            $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
        });
        </script>

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法言说的痛 2024-09-16 05:37:30

针对此特定 Google Visualization API 进行编辑:

.draw() 方法不是立即执行的,它仍然有一些工作要做,并且在当前情况下不会执行此操作线程(因为它可能需要从服务器等检索图像)。不过,他们提供了一个事件侦听器,您可以使用它来侦听 < code>ready 事件,如下所示:

google.visualization.events.addListener(visualization, 'ready', function() {
  $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
});

在这两行之间添加此代码,以便确保触发:

visualization = new google.visualization.Table(document.getElementById('table'));
visualization.draw(data, {'allowHtml': 'true'}, {'showRowNumber': 'true'}, {'firstRowNumber': '1'});

这将确保 .prettyPhoto1() 在所有元素(包括可视化中的元素)加载并准备就绪后运行。在这种情况下,仍然忽略 document.ready,只运行插件一次。

Edit for this specific Google Visualization API:

The .draw() method isn't immediate, it still has some work to do and it doesn't do it in the current thread (since it may need to retrieve an image from a server, etc). They offer an event listener though, you can use it to listen for the ready event, like this:

google.visualization.events.addListener(visualization, 'ready', function() {
  $(".gallery a[rel^='prettyPhoto']").prettyPhoto1({theme:'facebook'});
});

Add this code between these two lines so it's sure to fire:

visualization = new google.visualization.Table(document.getElementById('table'));
visualization.draw(data, {'allowHtml': 'true'}, {'showRowNumber': 'true'}, {'firstRowNumber': '1'});

This will ensure the .prettyPhoto1() runs after all the elements are loaded and ready to go, including the ones in the visualization. Still leave out the document.ready in this case, only run the plugin once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文