Nodebb Widget and Define()

  • Hey,

    Is there a way to reach define scoped javascript when using a widget? I am just trying to wrap the javascript code into a js file for my widget instead of having it in the template in script tags.

    I am trying to do something like below and i'm realatively new to JS and I have gotten this working perfectly when I am going to a route that I've added just can't get it to work when I am rendering widgets...

    define('forum/widgets/recruitment', [''], function () {
    'use strict';

    var recruitment = {};
    recruitment.init = function(){

    return recruitment;

  • Community Rep


    I think What you are looking for is require() Assuming you have placed your define in the Custom Header section, you would enter this into an HTML widget to call it.

    require(['forum/widgets/recruitment'], function (module) {

  • Thank you!

    I am a super noob to require JS and I had a feeling it was something related to calling a require but just am still trying to get used to the frameworks in play 😛



Looks like your connection to NodeBB was lost, please wait while we try to reconnect.