DataTables plugin for jquery and click event

datatables 1.6.2

 

 

I am trying to succeed at getting this jquery plugin to work corretly. What I need is a click event that will alow me to click a row and have a js window that will load another page using the row_id that is the primary key in the database. I'm really lost with javascript but I like the plugin and really would like to have this work if possible. I have been at this for a couple of days now. I know I'm close but haven't hit the mark yet. If someone could please help me, I'd be really grateful. I am using json to import the data.

 

Here is my current code. It will compile now but the .click event won't fire. :/

$(document).ready(function() { 
  oTable = $('#search').dataTable( 
  { 
    "sPaginationType": "full_numbers", 
    "bProcessing": true, 
    "iDisplayLength": 15, 
    "sAjaxSource": 'json.php', 
    "fnInitCallback": function () 
    { 
      $(oTable.fnGetNodes() ).click(function () 
      { 
        //alert(); 
      }); 
    } 
  }); 
}); 
 
 

You need to replace fnInitCallBack with fnInitComplete and it will work.
 
 
oTable = $('#search').dataTable({ 
    "sPaginationType": "full_numbers", 
    "bProcessing": true, 
    "iDisplayLength": 15, 
    "sAjaxSource": 'json.php', 
    "fnInitComplete": function (){ 
        $(oTable.fnGetNodes()).click(function (){ 
          // my js window.... 
        }); 
    } 
}); 

 

 

 

 

 

 

要对选定的 该行内的 html标签进行选择,可以使用以下代码

详细地址来源   :、

http://www.datatables.net/examples/api/row_details.html

 

$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var nTr = this.parentNode.parentNode;
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "../examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "../examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值