Skip to content

Commit

Permalink
9f7bbc77a204392ce37883057264b4be2ebbfcb4 Fix: -api ready() would ru…
Browse files Browse the repository at this point in the history
…n with the wrong context if it had to wait for `-event init`.

https://datatables.net/forums/discussion/80483/

Sync to source repo @9f7bbc77a204392ce37883057264b4be2ebbfcb4
  • Loading branch information
dtbuild committed Jan 23, 2025
1 parent 5e76e27 commit 74bd818
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "2.2.1",
"last-sync": "75afaf74aafa9f57509c0d2cce8d45d15ac6ee67"
"last-sync": "9f7bbc77a204392ce37883057264b4be2ebbfcb4"
}
6 changes: 4 additions & 2 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -9845,12 +9845,14 @@
// Function to run either once the table becomes ready or
// immediately if it is already ready.
return this.tables().every(function () {
var api = this;

if (this.context[0]._bInitComplete) {
fn.call(this);
fn.call(api);
}
else {
this.on('init.dt.DT', function () {
fn.call(this);
fn.call(api);
});
}
} );
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.min.mjs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9810,12 +9810,14 @@ _api_register( 'ready()', function ( fn ) {
// Function to run either once the table becomes ready or
// immediately if it is already ready.
return this.tables().every(function () {
var api = this;

if (this.context[0]._bInitComplete) {
fn.call(this);
fn.call(api);
}
else {
this.on('init.dt.DT', function () {
fn.call(this);
fn.call(api);
});
}
} );
Expand Down

0 comments on commit 74bd818

Please sign in to comment.