Issue loading the DateTime library: the first time, the Editor don't see it?

Issue loading the DateTime library: the first time, the Editor don't see it?

gbraultgbrault Posts: 5Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
At the first ever load in a browser (needs to clear cache to reproduce this event) I have the DateTime which is not set in the Editor. With the following code, I manage to succeed just reloading the page.
After the cache is loaded, I have no issue anymore.

Any idea?

    require.config({
        paths: {
            jquery: 'https://code.jquery.com/jquery-3.5.1.min',
            moment: "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min",
            "datatables.net": 'https://cdn.datatables.net/v/dt/dt-1.12.1/jquery.datatables',
            "datatables.net-editor": '/files/crud/lib/Editor/js/dataTables.editor',
            "datatables.net-buttons": 'https://cdn.datatables.net/v/dt/b-2.2.3/jquery.datatables',
            "datatables.net-colvis": 'https://cdn.datatables.net/v/dt/b-colvis-2.2.3/jquery.datatables',
            "datatables.net-select": 'https://cdn.datatables.net/v/dt/sl-1.4.0/jquery.datatables',
            "datatables.net-datetime": 'https://cdn.datatables.net/v/dt/date-1.1.2/jquery.datatables'
        }
    });

    require(["jquery",
             "moment",
             "datatables.net",
             "datatables.net-buttons",
             "datatables.net-colvis",
             "datatables.net-select",
             "datatables.net-editor",
             "datatables.net-datetime",
             ], ($) => { if ($.fn.dataTable.Editor.DateTime==null){
                            window.location.reload()
                         }
                         var checkExist = setInterval(function() {
                            if ($('#{{idcomm}}').length) {
                                var elt = document.querySelector('#{{idcomm}}');
                                elt.tojs_callback(window.dt.elt.bind(elt));            
                                window.dt.display_table.bind($);
                                window.dt.display_table();
                                clearInterval(checkExist);
                            }
                         }, 1000); // check every 1s              
             }
        );      

Answers

  • gbraultgbrault Posts: 5Questions: 1Answers: 0

    NB: If I don't use the DateTime lib, the code just works!

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Can you link to a test case showing the issue please?

    What happens if you load DateTime before Editor?

    Allan

  • gbraultgbrault Posts: 5Questions: 1Answers: 0

    I'll will setup something.

  • gbraultgbrault Posts: 5Questions: 1Answers: 0

    @allan I sent you a private email, using the contact form, where you have a link to a site in operation.
    Please use firefox as chrome as some issue to debug modules.
    The code has some debugger; directive and you'll be able to catch the lines above.
    Let me know if you have some issues.

  • gbraultgbrault Posts: 5Questions: 1Answers: 0

    Of course to get to the debugger; directive, you need to open the developers tools of the browser.

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Many thanks - I've replied to your e-mail.

    Allan

Sign In or Register to comment.