Composer tpl - add custom data.
-
Im working with the composer popup (not the one on the blank page). I'm looking for a server hook like filter:composer.build to add new data into that tpl. I couldn't see any hook fired (./nodebb dev) when you open the composer popup.
-
This is because the popup composer is rendered client side, if you want to add data you should be able to use
'filter:composer.create'
client side. https://github.com/NodeBB/nodebb-plugin-composer-default/blob/master/static/lib/composer.js#L495 -
@baris that event doesn't seem to be firing. Im using composer redactor.
this is my code in the client side
(function ($) { // in your plugin client side $(window).on('filter:composer.create', function(ev, data) { const postData = data.postData; const createData = data.createData; console.log(postData); console.log(createData); return { postData: postData, createData: createData } }); }); })(jQuery);
-
@sebastián-cisneros said in Composer tpl - add custom data.:
$(window).on('filter:composer.create', function(ev, data) {
Ahh, since this is a filter hook you will have to use the hooks module. Try this
require(['hooks'], function (hooks) { hooks.on('filter:composer.create', function (data) { console.log(data); return data; }); });
The upside is with the hooks module you can make async requests to the server to get more data and augment the
data.createData
object. This wasn't possible withaction
hooks. -
@baris you are a rock star!