Helper function not working at initial page load
-
Hi community, I am working on customizing the persona theme, and I need to override the generateChildrenCategories helper that comes with NodeBB. I successfully overrode the function and it's rendering my customized subcategories.
BUT it only works if I click on any of the links that take me to /category . If I refresh the page, the helper function does not work (not called or not yet initialized I guess), it renders no subcategory icon at all. Same happens when first landing at the forum as well.
Here is my code
library.jslibrary.init = function(params, callback) { ... templates.registerHelper('myGenerateChildrenCategories', function (category) { ... return html; }; callback(); };
persona.js
$(document).ready(function() { ... templates.registerHelper('myGenerateChildrenCategories', function (category) { ... return html; }; ... }
item.tpl
<!-- IF !config.hideSubCategories --> {function.myGenerateChildrenCategories} <!-- ENDIF !config.hideSubCategories -->
-
@genesisx sounds like the server-side helper is not registered correctly. Maybe try adding a
console.log
near it to confirm the code is being executed? -
@genesisx
init
isn't special, it's just the normal method name we use for thestatic:app.load
hook