2012-06-03 43 views
0

我想彈出基於一個jQuery腳本模式窗口在http://communitychessclub.com/js/jquery.popupWindow.js如何將<tr>中的data-href傳遞給jquery腳本?

我的測試頁面是在http://communitychessclub.com/games_new.php

我使用PHP來生成一個表,我有數據HREF觸發整個表格行(元組)可點擊加載遊戲。我有最新的jQuery加載和:

<script src="js/jquery.popupWindow.js"></script> 
<script>$('.example').popupWindow({centerScreen:1});</script> 

但彈出的窗口是空白的,在此基礎上:

<tr class="example" data-href="games/game1302.php"> 

我怎樣才能解決這一行:

<script>$('.example').popupWindow({centerScreen:1});</script> 

so that it picks up the url specified as data-href of the <tr> ? 

回答

1
$('.example').each(function(){ 
    $(this).popupWindow({centerScreen:1, windowURL: $(this).data("href")}); 
}); 

編輯。把它放在一個循環中,所以$(this)是有效的。另外,我注意到你在你的data-href中包含了完整的URL,所以現在不需要包含window.location.hostname

+0

沒有工作:只是一個空白的窗口加載,沒有內容。 – verlager

+0

您可能需要預先填寫整個網址。包括'window.location.hostname'或其他東西。或者在你的'data-href' attr中包含FULL url。 – ahren

+0

我試過但它仍然顯示一個空白的彈出式模式。 – verlager

相關問題