2011-08-25 50 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