You shouldn't need to link again, you should only have to run ./nodebb build -d && ./nodebb dev after you make a change.
You can also use grunt to automatically build and restart after making changes.
submit
button.Is there any client-side hook that invoke upon topic submission (#2) before going to server?
Thanks!
No, afaik, there are no filter hooks for the client-side.
Is there a reason why this can't be server-side? It seems to me to be a natural fit for the server hooks.
In any case, you could attach a click handler to the submit button on during the composer load hook, and edit the post there.
@yariplus Thanks for your suggestions. I just found out that the default composer validates for 0 content length on the client-side, which mean I have to modify the codes there. And the reason it has to be on client-side is because the composer will block the topic submission if the content is empty.
Oh, interesting. In that case I would use jquery to attach a .click listener on the submit button, checking for and inserting the textarea content. A little messy, but it should work.
Uh, hmm, proxy composer.enhance, this is called after the button is created but before the event is.
require(['composer'], function (composer) {
var orig = composer.enhance;
composer.enhance = function (postContainer, post_uuid, postData) {
postContainer.find('.composer-submit').click(function () {
postContainer.find('textarea').val('This is automagically posted.');
});
orig(postContainer, post_uuid, postData);
};
});
We have a hook that is fired client side right before the data is sent to the server.
$(window).trigger('action:composer.submit', {composerEl: postContainer, action: action, composerData: composerData});
https://github.com/NodeBB/nodebb-plugin-composer-default/blob/master/static/lib/composer.js#L577