A section of my template is not loading (unless I refresh the page).
-
So, I'm creating a custom route to use with my plugin by using a template along with some javascript code inside the static/lib directory.
Now, whenever I load the page, a piece of code inside the template is not getting loaded unless I refresh the page while on it.
This is the code that doesn't get displayed:
{{{ if (isOwner || (isStaff && (!character.validated || !character.editable))) }}} <div class="container mt-3 ps-0"> {{{ if (isOwner && character.editable) }}} <a href="/rpg/character/edit?uid={character.owner_id}" role="button" class="btn btn-secondary">Editar</a> {{{ end }}} {{{ if (isStaff && !character.validated) }}} <button id="validate-character-sheet" class="btn btn-secondary">Aprobar</button> <button id="fix-character-sheet" class="btn btn-secondary">Solicitar corrección</button> {{{ end }}} {{{ if (isStaff && !character.editable) }}} <button id="allow-edit-character-sheet" class="btn btn-secondary">Habilitar edición</button> {{{ end }}} </div> {{{ end }}}
Every validation and button inside of it works just fine once I refresh the page.
Is there anything I'm doing wrong in here?
-
How are you creating and rendering this custom route in your plugin? Is all the data supplied to it in the
res.render
call?NodeBB uses the data from
/api/your_custom_route
to render the template client side when you navigate to it, if you hit f5 on/your_custom_route
then the page is rendered server side. Sounds like the data isn't available in/api/your_custom_route
-
I don't know why, but taking those conditionals checks that I have to the route controller fixed the problem. I don't need to reload the page anymore.