1
我目前正在使用DataTable和對話框。但是,似乎只能在第一次點擊時打開對話窗口。每增加一次點擊都會打開網站,但不會打開對話窗口。Jquery Datatable對話框 - 對話框僅打開第一個對話框
任何人都可以看到失敗?代碼如下
<script type="text/javascript" charset="UTF-8">
$(document).ready(function() {
function DialogInformation() {
var $link = $(this);
var $dialog = $('<div></div>').dialog({
autoOpen: false,
title: $link.attr('title'),
width: 800,
height: 400,
modal: true,
open: function()
{
$(this).load($link.attr('href'));
}
});
$dialog.dialog('open');
return false;
};
$('##named_datatable').dataTable({
"iDisplayLength": 10,
"bInfo" : false,
"bProcessing": false,
"bServerSide": false,
"sAjaxSource": 'getLists',
"sPaginationType": "full_numbers",
"aoColumns": [
{ "mDataProp": "Title" , "sTitle": "Titel"},
{ "mDataProp": "Info", "sTitle": "", "sClass": "info", "mRender": function (data, type, row) {
return '<a href="getLists/'+ data +'" title="Information -'+ row.Title + '" class="info">Info</a>'; }
},
{ "mDataProp": "Min" , "sTitle": "Min"},
{ "mDataProp": "Price" , "sTitle": "Preis"},
"fnDrawCallback": function() {
//bind the click handler script to the newly created elements held in the table
$('tbody td.info a.info').bind('click',DialogInformation);
}
});
});
這可以在'ready()'本身完成,不需要使用'fnDrawCallback' – 2013-02-13 02:46:49