- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们可以在弹出的 fancybox 中绘制谷歌图表吗?
我的数据显示在表格中,每行都有一个按钮用于显示每条记录的谷歌图表。
目前,我的图表始终显示在表格后面的底部,但是当记录滚动到屏幕上时,用户需要滚动到底部才能获取图 TableView 。是否可以使用 fancybox 或某种方法来解决这个不方便的问题?
感谢您的建议!
html:
<table>
<tr>
<td> data </td>
...
<td>
<button onclick="showChartByEmpId()"> pie chart </button>
</td>
</tr>
</table>
<div class="secondary"> </div> <!-- showing chart here -->
js:
function drawPieChart(dataArr, elementId) {
//dataArr : the data to display
//elementId : <div> element where to display chart
var data = google.visualization.arrayToDataTable(dataArr);
var chart = new google.visualization.PieChart(document.getElementById(elementId));
chart.draw(data, options);
}
function showChart(){
//alert("readyState=" + xhr2.readyState);
if(xhr2.readyState == 4) {
if(xhr2.status == 200){
var allEmp = xhr2.responseText;
var empList = JSON.parse(allEmp);
... prepare pieChartDate[] to draw chart ...
//create <div> to displaying chart in it
$('.secondary').html('<div id="chart_div" height="450" width="450"></div>');
drawPieChart(pieChartData[0], "chart_div");
...
}
function showChartByEmpId(){
var url = '/CMP/employee/emp.do';
//create XMLHttpRequest
xhr = createXHR();
if( xhr == null ){
alert("no xhr creted");
return;
}
var requestData = "action=getOneEmpJSON&empId1=" + escape(empId1) + "&empId2=" + escape(empId2);
xhr.open('POST', url, true);
xhr.onreadystatechange = showChart;
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(requestData);
}
最佳答案
我会做什么:
1).隐藏 .secondary
div
<div class="secondary" style="display:none"></div>
2).为每个按钮分配一个类选择器,例如
<button class="doPiechart">pie chart</button>
3).将click
事件绑定(bind)到每个
按钮,然后在创建后在fancybox中显示#chart_div
的内容。
jQuery(function ($) {
$(".doPiechart").each(function (i) {
$(this).on("click", function () {
showChartByEmpId(i);
$.fancybox("#chart_div");
}); // on click
}); // each
});
注意,您可能需要调整 showChartByEmpId()
函数以传递 .each()
方法的索引,并最终到达包含一个回调以在完成后显示 fancybox。
查看 JSFIDDLE中的模拟行为 使用 fancybox v2.x
注意:.on()
需要 jQuery v1.7+
关于jquery - 如何从按钮 onclick 事件启动 fancybox 来绘制谷歌图表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18579054/
我有三个 html 页面,index.html、first.html 和 second.html。在索引页中,我有一个按钮 B1。当我单击该按钮时,会打开一个精美的框,其中包含 first.html
在我的网站上,我有一个 fancybox,其中包含隐藏的 的内容。在页面上。这个隐藏包含指向外部站点的链接。 是否可以在已经打开的 fancybox 中打开此链接? 我目前的代码如下: $("#li
Here我的链接是花哨的盒子,在笔记本电脑和台式机的所有浏览器中都可以正常工作,但是当您在移动设备(尤其是 I-PAD 这样的移动设备)中打开它时,叠加层会隐藏整个内部 html 内容。非常感谢您的回
我正在使用带有自定义模板的 fancybox-3 插件: $().fancybox({ selector : '[data-fancybox="images"]', animati
我正在尝试通过 Fancybox 内容中的链接关闭 Fancybox 实例。我正在按照 this question 中的建议使用 parent.jQuery.fancybox.close(); .它第
我使用 fancybox 作为联系表单。并在页面加载时打开。所以我使用了以下代码。 jQuery.fancybox.open('#fancy'); 我已经尝试过这个,但 fancybox 在加载时无法
如果脚本仅在 Fancybox 打开的页面上加载,CKEditor + Fancybox 似乎可以工作。然而,如果父页面已经初始化了 CKEditor,那么任何 Fancybox 打开的带有 CKEd
我有关于 Fancybox 3 的问题。我的网页有很多(10-15)个图片库,每个图片库大约有 50 张图片。每个画廊在主页上都有一个图片链接。 什么fancybox使用更好/更有效?: 不带缩略图使
从 2.x 升级到 3.0 后,我的应用程序崩溃了。新版本有没有类似的功能 $.fancybox.showLoading(); $.fancybox.helpers.overlay.open(); 最
转到:http://fancybox.net/打开任何示例(在底部页面) 当鼠标悬停在 fancybox 内的内容上时,浏览器主窗口无法滚动。当鼠标在其他地方时它就可以工作。我不想要这种行为。你会如何
How do I open fancybox via manual call for a gallery in the html not via the jquery options? 这回答了手动打
当用户关闭 Fancybox 对话框时如何重新加载当前页面? 最佳答案 使用 fancybox onClosed 处理程序; $('#some_element').fancybox({ onClo
我想要一个按钮来打开带有特定图片的 fancybox rel-group。我不太确定这是否有效,但我会试一试。我的问题是,如果用户单击链接,我想执行 jQuery。这是我的代码 var js = "j
我遇到了 fancybox 加载缓存图像的问题。我想确保图像在出现在页面上之前不被缓存,但是我试图通过它的各种回调(beforeShow、afterShow、afterLoad、beforeLoad)
我正在尝试编写一段代码,在用户单击 fancybox 中的其中一个选项后(选择一个选项后 fancybox 将关闭) 这是我的代码 索引.php Field: 选择字段.php
我坚持为我的照片设置 Fancybox 窗口,我是这样做的: $(document).ready(function() { $('.fancybox').fancybox(); }); 这是Fa
我想打开一个花哨的盒子,但是它给出了一个类型错误,你能帮我解决这个问题吗 查看页面包含以下代码 $(document).ready(function() { $('.fancybox').fancy
我有 2 个 fancyboxes,我试图从第一个打开第二个(通过按钮或关闭第一个).. I'm the first Fancybox! Close first Fancybox
嗨,我正在尝试将变量从子 iframe fancybox 发送到父级。但我似乎无法掌握如何做到这一点。有没有人有想法。我已经尝试过用js了。有 friend 建议用php来做,但还没有找到解决方案。我
我想知道一种加载我的 fancybox 并将 fancybox 附加到此 fancybox 中的链接之一的方法。我从今天开始使用最新版本的 fancybox (2.0.1)。 这是我尝试过但没有成功的
我是一名优秀的程序员,十分优秀!