Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda