jQuery datatables in qtip2 popup

▼魔方 西西 提交于 2019-12-25 06:20:44

问题


I would like to insert the jQuery datatables table in a qtip2 popup. I did this test: http://jsfiddle.net/fDavN/5588/

But the search and pagination are not shown.

$(document).ready(function() {

    $('.btn-layer').each(function() {    
    $(this).qtip( {
        content: {
            text: 'Loading...',            
            title: {
                text: 'User',
                button: true
            },
            ajax: {
                url: '/echo/json/',
                type: 'GET',
                dataType: 'text',
                cache: false,                
                //dataType: 'json',
                //contentType: 'application/json; charset=utf-8',
                //dataType: 'json',
                //data: { id: c_id },
                success: function(data) {
                    //var data = eval('(' + data + ')');                                        
                    data = testJson;                    
                    var $tab = $('<table class="table table-striped table-bordered dataTable" id="tbl1"></table>');                                                               
                    $($tab).dataTable({                    
                        "aaData": data.aaData,
                        "aoColumns": data.aoColumns
                    });
                    this.set('content.text', $($tab) );
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert('AJAX error!');
                } 
****


});

Ideas?

Thanks!


回答1:


I use jquery datatables lot and I think you problem is that you didn't add the element <table class="table table-striped table-bordered dataTable" id="tbl1"></table> into your page. I did the change of your code but didn't get time to test it. you can have a try.

success: function(data) {
    //var data = eval('(' + data + ')');                                        
    data = testJson;                    

    $('<table class="table table-striped table-bordered dataTable" id="tbl1"></table>').appendTo('body').dataTable({                    
        "aaData": data.aaData,
        "aoColumns": data.aoColumns
    });
    this.set('content.text', $($tab) );
},


来源:https://stackoverflow.com/questions/15267790/jquery-datatables-in-qtip2-popup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!