Jquery Datatable对话框 - Dialog仅打开第一个

时间:2013-02-12 16:41:24

标签: jquery dialog datatable

我目前正在使用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);
        }
    } );
} );

1 个答案:

答案 0 :(得分:1)

.bind()在'domready'处附加click事件。使用像这样的.on附加事件处理程序

$('tbody').on('click', 'td.info a.info',DialogInformation);