Re-render component without refreshing page
-
I'm currently writing a plugin to re-toggle the layout of partial lists. Now I add layout settings in user settings. How should I read the user settings and switch the tpl I want so the page can switch to a different layout? Is there any function method that can re-render a component in a targeted manner?
-
If you want to re-render something client side you can use
const html = await app.parseAndTranslate('path/to/template', 'blockName', data);
Where block name is the name used in the tpl file for a loop like
{{{ each topics }}}
and then once the render is done you can replace the html with jquery$('#some-target').html(html);
.If you search core code you will see many uses of app.parseAndTranslate to update the DOM.
Copyright © 2024 NodeBB | Contributors