# How to trigger function on the click of Solution Button

**URL:** https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738
**Category:** Development
**Created:** [September 29, 2021, 10:28am UTC](https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738 "2021-09-29T10:28:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![saurabhmasc](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@saurabhmasc](https://meta.discourse.org/u/saurabhmasc)
#### Post date: [September 29, 2021, 10:28am UTC](https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738/1 "2021-09-29T10:28:06Z")

</div>

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](https://global.discourse-cdn.com/meta/original/3X/6/f/6f221ed3f26ad73defa61f4aa469b6475e50835b.png)

Thanks.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [September 30, 2021, 12:57pm UTC](https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738/4 "2021-09-30T12:57:20Z")

</div>

Hi Saurabh,

> [@saurabhmasc](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![saurabhmasc](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@saurabhmasc](https://meta.discourse.org/u/saurabhmasc)
#### Post date: [October 1, 2021, 8:01am UTC](https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738/5 "2021-10-01T08:01:22Z")

</div>

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.

 ![Accept_answer](https://global.discourse-cdn.com/meta/original/3X/6/4/64013a965192042fb3fc92f10fbb162b27545a02.png)

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.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 1, 2021, 12:21pm UTC](https://meta.discourse.org/t/how-to-trigger-function-on-the-click-of-solution-button/204738/6 "2021-10-01T12:21:43Z")

</div>

> [@saurabhmasc](#):
>
> 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.

Looks like a good solution 👍
