单击表格行应打开一个精美框
我尝试打开一个通过单击表行上任意位置触发的 fancybox。单击一行后,我在 Firebug 控制台中看到以下消息:
递归过多 http://code.jquery.com/jquery-1.7.js 2925行
这是我的 HTML:
<table id="allItems">
<tr class="itemRow">
<td><a href="http://www.google.com" class="foo">foo</a></td>
<td>bar</td>
</tr>
<tr class="itemRow">
<td><a href="http://www.bing.com" class="foo">bar</a></td>
<td>bar</td>
</tr>
</table>
这是我的 javascript:
var itemRow = $('#allItems tr.itemRow');
itemRow.click(function(e){
e.preventDefault();
$(this).find('.foo').trigger('click');
});
$('.foo').fancybox({
'href' : $(this).attr('href'),
'width' : '100%',
'height' : '100%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
您可以在这里找到一个实例:http://jsfiddle.净/svebal/zQ8FZ/
I try to open a fancybox triggered by a click anywhere on a table row. After click on a row, I achieve this message in the Firebug console:
too much recursion
http://code.jquery.com/jquery-1.7.js
Line 2925
Here is my HTML:
<table id="allItems">
<tr class="itemRow">
<td><a href="http://www.google.com" class="foo">foo</a></td>
<td>bar</td>
</tr>
<tr class="itemRow">
<td><a href="http://www.bing.com" class="foo">bar</a></td>
<td>bar</td>
</tr>
</table>
Here is my javascript:
var itemRow = $('#allItems tr.itemRow');
itemRow.click(function(e){
e.preventDefault();
$(this).find('.foo').trigger('click');
});
$('.foo').fancybox({
'href' : $(this).attr('href'),
'width' : '100%',
'height' : '100%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
A live example you can find here: http://jsfiddle.net/svebal/zQ8FZ/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
.trigger() 在一些浏览器/jquery 插件上非常不可靠。你想做:
.trigger() is pretty unreliable on several browsers/jquery plugins. You want to do:
实际上,您需要的唯一脚本是:
Actually, the only script you need is this:
如果您想在单击 tr 上的任何 td 后显示灯箱,则必须更改此行:
对此,
这将找到下一个元素下类为 foo 的元素
if you want to show the lightbox after clicking any td on the tr you must change this line:
to this
this finds the element which class is foo under the next element