Handlers on client side

Plugin Development
  • Hello,

    What handlers to bound to the window object to get list of topics/posts titles of certain category cid on the client side?

    Is that possible?

    Thanks

  • When you are on the category page you can access the topics with ajaxify.data.topics and on the topic page its ajaxify.data.posts.

    There are also hooks fired whenever new topics/posts are added. They are $(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics }); and $(window).trigger('action:posts.loaded', { posts: data.posts });


Suggested Topics


  • Client side pagination

    Plugin Development
    2
    0 Votes
    2 Posts
    83 Views

    I was able to use Categories.setCategoryField to tag the categories that are customized with topic cards and then use that attribute in the templates.

  • Hook on the server or client side?

    Solved Plugin Development
    2
    0 Votes
    2 Posts
    288 Views

    Hooks that are fired on the server side are only available for use for plugins in their server side code. Same for client side hooks they are only available for use in the client side code of plugins.

  • Get req username in server-side

    Solved Plugin Development
    4
    0 Votes
    4 Posts
    301 Views

    You need to make your controller async for it to work.

    init: async params => { RouteHelpers.setupAdminPageRoute(params.router, '/admin/plugins/myplugin', params.middleware, [], async (req, res) => { res.render('admin/plugins/myplugin', { username: await User.getUserField(req.uid, 'username') }) }) }
  • 0 Votes
    1 Posts
    1k Views

    Suppose there are two files.

    library.js in the /nodebb-plugin-namePlugin
    file.js in /nodebb-plugin-namePlugin/static/lib

    Now I must do a lot of operation in my library.js and I must check when user is created. So I use the hook and It's everything ok, but, after I must my check in library I need to send a message to my file.js to change background color of a component. The proble is that I used this to communicate:

    websockets = module.parent.require('./socket.io'), //library.js websockets.in('uid_' + data.uid).emit('hash', { 'username': data.data.username }); //file.js socket.on('hash',function(){ console.log("DOG); });

    The problem is that I don't have data.uid value because I'm checking before that an user can registrate himself. Anyone can help me to use websocket without uid or can suggest me other methods?

  • 0 Votes
    4 Posts
    2k Views

    Always makes me smile when I can help.
    Your plugin also opened nodeBB to a more scientific audience, which I personaly find extra apealing. 🙂