integrating in wordpress plugin

integrating in wordpress plugin

riz666riz666 Posts: 2Questions: 1Answers: 0
edited November 2014 in Free community support

I am trying to use the datatables with the editor in my wordpress plugin and i am having hard time integrating.

I used the generator to download a package.
I setup the table in the same database as the wordpress
I setup the options page as such:

I have asked this on stackexchange.com:
http://wordpress.stackexchange.com/questions/169655/integrating-jquery-datatables-with-editor-into-wordpress-admin

have a look there its more readable.

$(document).ready(function() {
        var editor = new $.fn.dataTable.Editor( {
            "ajax": "admin-ajax.php?action=datatables",
            "table": "#id",
            "fields": [
                {
                    "label": "first",
                    "name": "first",
                    "type": "text"
                },
                {
                    "label": "last",
                    "name": "last",
                    "type": "text"
                },
                {
                    "label": "age",
                    "name": "age",
                    "type": "text"
                }
            ]
        } );

        $('#id').dataTable( {
            "dom": "Tfrtip",
            "ajax": "admin-ajax.php?action=datatables",
            "columns": [
                {
                    "data": "first"
                },
                {
                    "data": "last"
                },
                {
                    "data": "age"
                }
            ],
            "tableTools": {
                "sRowSelect": "os",
                "aButtons": [
                    { "sExtends": "editor_create", "editor": editor },
                    { "sExtends": "editor_edit",   "editor": editor },
                    { "sExtends": "editor_remove", "editor": editor }
                ]
            }
        } );
    } );
            <div class="container">
            <h1>DataTables Editor - id</h1>
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="id" width="100%">
                <thead>
                    <tr>
                        <th>first</th>
                        <th>last</th>
                        <th>age</th>
                    </tr>
                </thead>
            </table>
        </div>

I can display the table data on my custom plugin page fine but when i click the New, Edit or Delete buttons on top I get a new form to fill out but when I click save it just spins there and doesn't do anything. I have setup the wordpress ajax functions as such.

add_action( 'wp_ajax_datatables', 'my_datatables_callback' );

function my_datatables_callback() {

     include( APFDEMO_DIRNAME . '/datatables/php/table.id.php' );

     die();
}

I am pointing both the datatables and datatables editor to

var editor = new $.fn.dataTable.Editor( {
            "ajax": "admin-ajax.php?action=datatables",

        $('#id').dataTable( {
            "dom": "Tfrtip",
            "ajax": "admin-ajax.php?action=datatables",

Could someone be willing to help me out with this

Thanks alot

Answers

  • allanallan Posts: 63,290Questions: 1Answers: 10,428 Site admin

    I can't help much with the WordPress aspect I'm afraid, but what does the server return from the Ajax request that Editor makes when you submit the form? Does it actually return anything? Are there any messages in the browser console or the server's error log?

    Thanks,
    Allan

  • riz666riz666 Posts: 2Questions: 1Answers: 0
    edited December 2014

    Console should this error:
    TypeError: c[((((((e0P + B9E) + r8) + O5E) + f0P) + t7E) + D7P)] is undefined
    ...error="";if(!c[(e0P+B9E+T4P+G7+t7E+D6)])c[(e0P+X5+f0P+y7P+t7E+p7E)]=[];if(c.erro...

    Here is the response from both the get and post

    For get to populate the table which is working fine:
    https://www.dropbox.com/s/1kbjoaayhkh84yo/dataCapture2.JPG?dl=0

    for the Post which gives a response of 0 yet the Post data is looking fine
    https://www.dropbox.com/s/1kbjoaayhkh84yo/dataCapture2.JPG?dl=0

    Response of 0
    https://www.dropbox.com/s/qjrfqx9q1cmaaar/dataCapture3.JPG?dl=0

  • allanallan Posts: 63,290Questions: 1Answers: 10,428 Site admin

    The response of 0 is what looks like is causing the Javascript error. We need to figure out why the server would be returning 0 as that isn't valid JSON, never mind being in the format that Editor expects.

    Are there any errors recorded in the server error log? Also, could you add a debug message to your die(); statement, just incase it is going that far?

    Thanks,
    Allan

This discussion has been closed.