2014-11-14 57 views
0

我使用的數據表在http://communitychessclub.com/test.php和得到看起來像這樣的AJAX數據:數據表表行不鏈接到URL

{ 
"data": [ 
{ 
"game": "5086", 
"date": "09/02/2013", 
"event": "135th NYS Ch.", 
"eco": "B08", 
"white": "Jones, Igor", 
"white_rating": "2393", 
"black": "Smith, Efim", 
"black_rating": "2268" 
}, 

我有這樣的不完整的代碼,並希望使錶行點擊,使得點擊會鏈接「basic.php遊戲=?‘的數據:遊戲’」

**$("#cccr tbody").delegate("tr", "click", function(e) { 
//rest of the code here 
});** 

我所問的是什麼樣的代碼替換「//這裏休息的代碼」?這是有關:window.location.href?

回答

0

你就要成功了,但不是必需的委託:

$(document).ready(function() { 
    var table = $("#example").DataTable(); 
    $('#example tbody').on('click', 'tr', function(){ 
     var row_date = table.row(this).data(); 
     console.log(row_date[0]); 
     window.location = "http://www.google.com/search?q"+row_date[0]; 
    }); 
}); 

here,它不會改變URI但因爲它會試圖改變一個iframe的源.. 。儘管你的用例可能不是問題。