Can't get editor to work

Can't get editor to work

thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0
edited July 2022 in Free community support

I have downloaded the php libraries and installed the demo - all works fine.
I did notice that everything in the 'Editor-PHP-2.0.8' folder was put into the public_html folder including the config file which is not good practice.

I have previously got datatables working fine but now struggling with Editor.
So following the successful install of demos, I have now:
1. Copied the libs folder into a folder outside of 'public_html' - is this correct or does it need to be in there?
2. Added what I think are the right .css and .js links to header using the datatables tool to build the links for me
3. Modified the config.php file to add my db settings
4. Copied line for line the demo from Editor-PHP-2.0.8/examples/simple/server-side-processing.html into my project

When it runs, there are no errors but all I see are the table head and tail ie.. data is not being rendered at all. I can't see any errors in the server log or the php_errorlog

Unsure how to paste the code in here to maintain formatting.
Anything obvious/gotchas I should be looking at?

I am presuming if editor can't connect to the db and table then error will be thrown.

Thank you!

This question has an accepted answers - jump to answer

Answers

  • thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0

    So I have just opened the browser console and can now see this message:

  • thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0

    Fixed it. I didn't realise the var had to be called 'editor'
    Sorry to clog up this forum.
    This can now be closed.

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    It doesn't need to be called editor. You might be including the demo.js file perhaps? It does specifically look for an editor variable, but it is only relevant for our demos and shouldn't be included anywhere else.

    Allan

  • thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0

    Thanks Allan. That is odd because as soon as I changed it then all started working. I can't see that I am including demo.js but will double check

  • thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0
    edited July 2022

    @allan I definitely can't get it to work unless I user the var name 'editor'.

    This code works:

    var editor; // use a global for the submit and return data rendering in the examples
    
    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            "ajax": "admin_users.php",
            "table": "#user_table",
            "fields": [ {
                    "label": "Name:",
                    "name": "name"
                }, {
                    "label": "Email:",
                    "name": "email"
                }, {
                    "label": "Role:",
                    "name": "role"
                }
            ]
        } );
    

    whereas this one doesn't (the table just isn't rendered) and the error in the console is 'editor is not defined':

    var editor2; // use a global for the submit and return data rendering in the examples
    
    $(document).ready(function() {
        editor2 = new $.fn.dataTable.Editor( {
            "ajax": "admin_users.php",
            "table": "#user_table",
            "fields": [ {
                    "label": "Name:",
                    "name": "name"
                }, {
                    "label": "Email:",
                    "name": "email"
                }, {
                    "label": "Role:",
                    "name": "role"
                }
            ]
        } );
    
    

    The js scripts I am including in the header are:

    <!-- Datatables JS Scripts  https://datatables.net/download/ -->
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
        <script type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.12.1/af-2.4.0/b-2.2.3/b-colvis-2.2.3/b-html5-2.2.3/b-print-2.2.3/date-1.1.2/fc-4.1.0/fh-3.2.4/kt-2.7.0/r-2.3.0/rg-1.2.0/sc-2.0.7/sb-1.3.4/sp-2.0.2/sl-1.4.0/sr-1.1.1/datatables.min.js"></script>
        <script type="text/javascript" src="js/dataTables.editor.js"></script>
    
    

    What am I missing?

    thanks

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Not sure! Are you using the editor variable for the Buttons (create, edit and remove) perhaps? We tend to use the name editor so if you've copy and pasted the DataTables initialisation, that might be the issue.

    If it isn't that, can you show me your full JS file?

    Thanks,
    Allan

  • thefireescaperthefireescaper Posts: 11Questions: 3Answers: 0

    Thanks @allan . Don't think it is the duplicate var for buttons. For the form it is failing am not using buttons.

    Do you mean the full contents of js/datatables.editor.js file ?

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    No - I was thinking of the file that editor2 = new $.fn.dataTable.Editor( { and friends are included in.

    Allan

Sign In or Register to comment.