您的位置:首页 > Web前端 > JQuery

DataTables plugin for jquery and click event

2010-05-24 12:30 429 查看
datatables1.6.2

Iamtryingtosucceedatgettingthisjqueryplugintoworkcorretly.WhatIneedisaclickeventthatwillalowmetoclickarowandhaveajswindowthatwillloadanotherpageusingtherow_idthatistheprimarykeyinthedatabase.I'mreallylostwithjavascriptbutIlikethepluginandreallywouldliketohavethisworkifpossible.Ihavebeenatthisforacoupleofdaysnow.IknowI'mclosebuthaven'thitthemarkyet.Ifsomeonecouldpleasehelpme,I'dbereallygrateful.Iamusingjsontoimportthedata.

Hereismycurrentcode.Itwillcompilenowbutthe.clickeventwon'tfire.:/

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



[code]YouneedtoreplacefnInitCallBackwithfnInitCompleteanditwillwork.



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


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

[/code]
详细地址来源:、

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

$('tdimg',oTable.fnGetNodes()).each(function(){
$(this).click(function(){
varnTr=this.parentNode.parentNode;
if(this.src.match('details_close'))
{
/*Thisrowisalreadyopen-closeit*/
this.src="../examples_support/details_open.png";
oTable.fnClose(nTr);
}
else
{
/*Openthisrow*/
this.src="../examples_support/details_close.png";
oTable.fnOpen(nTr,fnFormatDetails(nTr),'details');
}
});
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐