Skip to content

Commit bbecf7e

Browse files
committed
simplified example
1 parent c414496 commit bbecf7e

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

docs/events.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,14 @@ Triggered right after the `hit` event. Indicating that the next page will be loa
7474

7575
> pageIndex is zero indexed. This means the index starts at 0 on the first page.
7676
77-
For example to get the url and title of the new page, you can do:
77+
For example to notify the user about loading the next page, you can do:
7878

7979
```js
8080
ias.on('next', function(event) {
81-
// fallback on url and title of current page
82-
let url = document.location.toString();
83-
let title = document.title;
84-
85-
const onLoaded = (event) => {
86-
url = event.url;
87-
title = event.xhr.response?.title ?? title;
88-
}
89-
90-
ias.once('loaded', onLoaded)
81+
alert(`Page ${event.pageIndex+1} is loading...`);
9182

9283
event.promise.then(function() {
93-
alert(`We just loaded ${url} with title ${title}`)
94-
95-
ias.off('loaded', onLoaded);
84+
alert(`Page ${event.pageIndex+1} is loaded and added to the page.`);
9685
});
9786
});
9887
```

0 commit comments

Comments
 (0)