Datatable loads then removes

Datatable loads then removes

phsycomigphsycomig Posts: 9Questions: 5Answers: 0

Hello,

I apologies that i cannot provide any live demo, as i currently run umbraco on my system.

i have a main page which calls a partial, this partial calls another partial and is working like a controller, which in the end provides me with a html table.

on my main page i have a script to reload the partials, and not the whole page.

This is my main page

@if (allowed)
{
    <div class="m-scene" id="main" style="margin-top: 1rem">
        <div class="m-header scene_element scene_element--fadein scene_element--delayed">
            <div class="containerTable" id="tables">
                @Html.GetGridHtml(Model.Content, "table")
            </div>
        </div>
    </div>
}
else
{
    Html.RenderPartial("/Views/Partials/Root/Settings/404.cshtml");
}

<script>
    $(document).ready(function() {
        function refresh() {
            $("#tables").load(location.href + " #tables");
            setTimeout(refresh, 15000);
        }
        refresh();
    });
</script>

in the end, i will end up with a table, as i do, and i can see the datatable plugin loads and applies, until very shortly after it removes it again and return to the state as it was never initialized. This happens over a timespan of 1-2 seconds.

this is my script i have in my table cshtml

<script>
    $(document).ready(function () {
        $.fn.dataTable.moment('DD-MM-Y');
        var table = $('#skader').DataTable({
            order: [$('#skader').find('th').length - 1, 'asc'],
            pageLength: 26,
            orderClasses: false,
            columnDefs: [
                {
                    orderable: false,
                    targets: [1]
                },
                {
                    bVisible: false,
                    aTargets: [0]
                }
            ],
            scrollY: '60vmin',
            scrollCollapse: true
        });
        $($.fn.dataTable.tables(true)).DataTable()
            .columns.adjust();
        $('.SkadeSearch').click(function () {
            table.column(0).search($(this).data('val')).draw();
        });
    });
</script>

I can give any information that you would ever want, pictures or code, doesn't matter. i just cannot figure out where it breaks, i have tried using the debugger tool, and it gives correct informations even though i don't see the datatable plugin on my table.

please help anyone

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @phsycomig ,

    This wouldn't be an issue with DataTables - tables aren't removed unless you explicitly destroy them in the API. It'll be something to do with your umbraco deployment or flow, so would be worth asking on their forums/site,

    Cheers,

    Colin

This discussion has been closed.