我嘗試打開表格行上任意位置點擊觸發的fancybox。點擊某行後,我在Firebug控制檯實現這一消息:Click on tablerow should open a fancybox
太多的遞歸調用 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.net/svebal/zQ8FZ/
下class是foo的元素適用於我的瀏覽器,沒有任何錯誤和可愛的fancybox。 –
當你點擊「一些數據」或「另一個數據」? O.O – skamander
嗯,不,看我的答案,使其工作就像那樣。 –