Is there a plugin or native setting that would allow me to set certain topic or category to be ignored for everyone (so that not everyone has to do it for themselves but still be able to unignore if they wish)?
I would like to let users post in certain topic / category but without triggering "unread" status (like off topic category etc.)
Any client-side hook before new topic submit?
-
Use-case
- User create a new topic.
- User click
submit
button. - Client-side check if the content is empty. If content is empty, insert "xxx" to content.
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