doc: add doc for dynamic comment loading

pull/452/head
Rocka 6 years ago
parent a87815fcba
commit 61b3b69557
No known key found for this signature in database
GPG Key ID: 28031158FFDD6853

@ -23,3 +23,34 @@ Now, either include `count.min.js` if you want to show only the comment count
You can have as many comments counters as you want in a page, and they will be
merged into a single `GET` request.
Asynchronous comments loading
-----------------------------
Isso will automatically fetch comments after `DOMContentLoaded` event. However
in the case where your website is creating content dynamically (eg. via ajax),
you need to re-fetch comment thread manually. Here is how you can re-fetch the
comment thread:
.. code-block:: js
window.Isso.fetchComments()
It will delete all comments under the thread but not the PostBox, fetch
comments with `data-isso-id` attribute of element `section#isso-thread` (if that
attribute not exists, fallback to `window.location.pathname`), then fill
comments into the thread. In other words, you should change `data-isso-id`
attribute of element `section#isso-thread` (or modify the pathname with
`location.pushState`) before you can get new comments. And the thread element
itself should *NOT* be touched or removed.
If you removed the `section#isso-thread` element, just create another element
with same TagName and ID in which you wish comments to be placed, then call the
`init` method of `Isso`:
.. code-block:: js
window.Isso.init()
Then Isso will initialize the comment section and fetch comments, as if the page
was loaded.

Loading…
Cancel
Save