jquery 和 google 表格可视化
我希望有人可以帮助我。我在同一页面上使用 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)%>&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>
谢谢
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
针对此特定 Google Visualization API 进行编辑:
.draw()
方法不是立即执行的,它仍然有一些工作要做,并且在当前情况下不会执行此操作线程(因为它可能需要从服务器等检索图像)。不过,他们提供了一个事件侦听器,您可以使用它来侦听 < code>ready 事件,如下所示:在这两行之间添加此代码,以便确保触发:
这将确保
.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 theready
event, like this:Add this code between these two lines so it's sure to fire:
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 thedocument.ready
in this case, only run the plugin once.