2011-08-25 64 views
0

时,我想打一个表行完全可点击通过嵌入隐藏<td>含有像这样的链接:阅读​​,然后负载弹出点击

<tr class="simplehighlight junk" > 
    <td>07/09/2011</td> 
    <td>Jennifer Woods Memorial GP</td> 
    <td>A52</td> 
    <td>Harris, Fred</td> 
    <td>1900</td> 
    <td>Nikolayev, Igor</td> 
    <td>2395</td> 
    <td class="text-center">0-1</td> 
    <td style='display:none;visibility:hidden;\'> games/game1242.php </td> 
</tr> 

我用颜色框为目标的表格单元格像这样:

<!--colorbox--> 
<script src="./js/jquery.colorbox-min.js"></script> 
<script> 
    $('tr.junk').colorbox(
    { 
     iframe:true, 
     transition:'elastic', 
     speed:'100', 
     width:1030, 
     height:550, 
     href: function(){ 
     return $(this).find('td').eq(8).text(); 
     } 
    } 
); 
</script> 

但我想使用jquery:

<!--Another Pop-up for games table--> 
<script src="./js/jquery.popupWindow-min.js" ></script> 
<script> 
    $('.diagram-popup').popupWindow({centerBrowser:1, height:560, width:1024}); 
</script> 

如何将类diagram-popup添加到第8个表格数据单元格,并单击该行时读取该单元格的内容?

回答

1
<td class='diagram-popup' style='display:none;visibility:hidden;\'> games/game1242.php </td> 

$(document).ready(function(){ 
    $('.diagram-popup').click(function(){ 
     $(this).html(); //contents of cell 
    }); 
}); 

这是你在找什么?

更新:啊,我看......你想点击行中的任意单元格,然后去获得内容..也许这将有助于...

<td style='display:none;visibility:hidden;\'> games/game1242.php </td> 

$(document).ready(function(){ 
    $('table tr td').click(function(){ 
     var cell = $(this).parent().find('td:last'); 
     cell.addClass('diagram-popup'); //Not clear on if this is what you're wanting, you can always just print out the diagram-popup class server side 
     cell.html(); //contents of cell 
    }); 
}); 

我的天堂没有测试过,但它应该起作用。

+0

它没有工作。也许有人可以检查http://communitychessclub.com/games-nu.php – verlager

1

你要一个类添加到您的可点击的行,我可能会改变tr问题阅读是这样的:

<tr class="simplehighlight junk diagram-popup" data-href="games/game1242.php" > 

而且我会完全放下你的隐藏<td>,这是不必要的。

而jQuery的:

<script src="./js/jquery.popupWindow-min.js" ></script> 
<script type='text/javascript'> 
    $(function(){ 
    $('.diagram-popup').click(function(e){ 
     $(this).popupWindow({ 
     windowURL: $(this).data('href'), 
     centerBrowser: 1, 
     height: 560, 
     width: 1024 
     }); 
    }); 
    }); 
</script> 

我有几分不具有窗口蹦出来,当我点击的东西的粉丝......我不认为它提出了一个良好的用户体验。但是对于他们自己。

这是一个jsfiddle作为概念验证:http://jsfiddle.net/UujmJ/1/

+0

DW的来源...并销毁DataTables。这是与DataTables功能原创:http://communitychessclub.com/games-save.php和基于您的建议(我非常感谢这项努力)的新版本是在这里:http://communitychessclub.com/games -nu.php – verlager

+0

嗯,在你的源中,我看到两个调用popupWindow,一个地雷,和一个没有URL的旧地址。大概应该只使用一个?如果我的答案为你工作,你应该接受它作为正确的:) :) – nzifnab

+0

我刚刚注释掉了另一个popupWindow,它仍然是DW。我几乎准备好接受你放弃“点击”想法并添加一个简单的​​加载游戏内核的建议。 – verlager