Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
Reloading table not working as it is undefined

Sorry for the poor title, I genuinely don't know how to title this question, but essentially what I am trying to do is, after everything has loaded on the page, I want to change a drop-down list selection and reload the table data, I have the following code:

@section Scripts {
@Scripts.Render("~/bundles/jobs")
<script type="text/javascript">
    $(function () {
        $("body").data("Jobs.Index", new Jobs.Index({
            detailsUrl: '@Url.Action("Details")',
            applyUrl: '@Url.Action("Apply")',
            keyword: '@Html.Raw(HttpUtility.JavaScriptStringEncode(keyword))',
            showMaxResultsByDefault: @settings.ShowMaxResultsByDefault.ToString().ToLower()
        }));
    });

    $(window).on('load', function () {
        if (showMaxResultsByDefault) {
            $('.koDataTable_pageSizesWrapper select').val('100');
            $('#jobsTable').load();
        }
    });
</script>

}

I needed to move the $(window).on(.... code to one of our existing .ts files, which is called in the $(function () {... code, so I added it right at the bottom of the code in the .ts file, but now it's giving the following error when hitting $('#jobsTable').load();:

Uncaught TypeError: Cannot read properties of undefined (reading 'indexOf')

By my understanding of the error, the jobsTable table does not exist yet, hence the error, but isn't it suppose to be created by now, considering it's in the $(window).on(... code? This should be running after everything on the page is loaded.

I can only think that it comes down to the order of events, so I'm missing something, as I thought that running the code in my $(window).on(... code, would run after the DOM was created, etc..

Been struggling with this silly thing for a couple of hours, help would be greatly appreciated!

It might be worthy to mention, I am using Knockout Data Tables to populate this table.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda