1

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

4

1 回答 1

1

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

$('tbody').on('click', 'td.info a.info',DialogInformation);
于 2013-02-13T02:38:07.203 回答