Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!