How to trigger function on the click of Solution Button

AI-generated summary

Triggering Function on Solution Button Click

saurabhmasc is looking for a way to display/hide a popup at the bottom of a topic page when a user accepts or unaccepts a reply as a solution by clicking the Solution button. This popup should be visible only to the topic author if no replies are marked as a solution.

zogstrip requested clarification on the requirements, and saurabhmasc provided a detailed explanation and mockups of the desired functionality.

saurabhmasc implemented a solution by creating a widget (accept-answer-popup) that returns the popup based on the required conditions. The widget is attached after the post-stream widget, allowing it to refresh when the Solution button is clicked.

zogstrip reviewed the implementation and provided positive feedback, indicating that it appears to be a good solution.

Hi All,

We are using discourse-solved plugin for accepting answers from the Users.
Now we have to display/hide a popup at the bottom whenever the user accepts/unaccepts a reply as an answer by clicking on the Solution button. How we can do this?

image

Thanks.

Hi Saurabh,

I’m not quite sure I understand what you’re asking. Can you explain what you mean by that? Maybe use a mockup if that’s easier?

Why do you want to display/hide a popup? What information do you want to display in that popup?

Thanks

Hi @zogstrip,

Thanks for the reply. We got the solution.

Here we have to display a popup similar to a cookie notice (i.e. fixed at the bottom) on the Topic page if the logged-in user is the author of the topic and none of the replies is marked as Solution.
And whenever the topic author checks/unchecks the reply as Solution then hides/shows the popup.

So for this, we have created a widget that returns the popup (say: accept-answer-popup) only based on the required conditions (as I mentioned above) and attached it after the post-stream widget.

By this whenever the topic author checks/unchecks the reply as Solution then the post-stream widget is refreshed and also the accept-answer-popup is refreshed as they are in the chain. This solved our problem.

Please give us feedback if we are missing anything in our implementation.

Looks like a good solution :+1: