RapiDoc
RapiDoc copied to clipboard
How to initiate Rapidoc from JS?
Is there a way to init Rapidoc completely from JS?
I have this in ajax-loaded content:
<div>
<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/rapidoc-min.min.js"></script>
<rapi-doc id="thedoc" data-json = "{$openApiJson}" ... some config options ...> </rapi-doc>
</div>
$openApiJson variable inserts the OpenApi json into this data-element.
In JS which runs on load after ajax is this:
const docEl = document.getElementById('thedoc');
if (docEl) {
let strSpec = docEl.dataset.json;
let objSpec = JSON.parse(strSpec);
docEl.loadSpec(objSpec);
}
That works, it loads the spec etc., but only, if I enter the page by browser url, without ajax.
If I´m going through app menu and content is being loaded by ajax, I have to enter that page twice to get Rapidoc rendered. Checking the browser network analysis, at first entry, rapidoc-min.js is loaded, but nothing gets rendered, I have to click menu again to load the page for second time to get the Rapidoc rendered.
It seems I need to somehow call "render Rapidoc" on the
Thx for any tips.