How to call on load event in newer JQuery versions

44 views Asked by At

It is seen that the Prior to jQuery 3.0, the event handling suite also had a method named .load() which has been deprecated in newer versions.

Use Case:

I need to highlight some rows in a table based on some style classes that was appended to the td of that row based on dynamic data and knockout.

<td data-bind="attr:{css: {emphasize: $context.row.firstRow}">

$('#table').ready(()=>
     let tableRowElement: JQuery = $('.emphasize').closest('tr');
     tableRowElement.addClass('highlight);
);

used to work in most cases but it fails in some cases as my function gets fired when the DOM is ready and before a particular style class has been updated using knock out.

If I can replace $('#table').ready() with $('#table').load() it should work but newer Jquery does not use load for event handling but it is used to Load data from the server and place the returned HTML into the matched element.

0

There are 0 answers