# Sovrascrittura del pulsante "toggle reply"

**URL:** https://meta.discourse.org/t/overriding-toggle-reply-button/120553
**Category:** Development
**Created:** [17 Giugno 2019, 6:06am UTC](https://meta.discourse.org/t/overriding-toggle-reply-button/120553 "2019-06-17T06:06:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ellibereth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ellibereth/32/202896_2.png) [@Ellibereth](https://meta.discourse.org/u/Ellibereth)
#### Post date: [17 Giugno 2019, 6:06am UTC](https://meta.discourse.org/t/overriding-toggle-reply-button/120553/1 "2019-06-17T06:06:52Z")

</div>

This is a repost from: [Could we get the link to post replies in mobile view? - #12 by Ellibereth](https://meta.discourse.org/t/could-we-get-the-link-to-post-replies-in-mobile-view/115791/12), but it probably belongs here in #Development and not in that topic.

I’m trying to modify the “toggleReplyAbove” action, to show a modal of the replied-to-post on mobile instead of jumping to the post (why we’re doing this is described in the above topic).

It looks to be in the post widget, but if I use the following code to try and replace the action I don’t see any effect - nothing is printed to console and it behaves as normal:

```plaintext
api.attachWidgetAction('post', 'toggleReplyAbove', () => {
    console.log('toggle triggered');
  });

```

In the post widget code, it looks like the toggleReplyAbove function is defined inside the created widget `post-article` , but that doesn’t seem to be modifiable with attachWidgetAction since the following code trying to modify that widget results in the error `Uncaught TypeError: Cannot read property 'class' of undefined` :

```plaintext
api.attachWidgetAction('post-article', 'toggleReplyAbove', () => {
    console.log('toggle triggered');
  });

```

I’m able to overwrite the “like” action on post-menu fine as described here [Updating Discourse Plugins, taking the first step - #9 by eviltrout](https://meta.discourse.org/t/updating-discourse-plugins-taking-the-first-step/41241/9). Where should I be attaching the widget action to overwrite the toggleReplyAbove action?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [18 Giugno 2019, 4:29pm UTC](https://meta.discourse.org/t/overriding-toggle-reply-button/120553/2 "2019-06-18T16:29:32Z")

</div>

Looks like this was a bug in the plugin api:

[https://github.com/discourse/discourse/commit/6fec4982d903cbb088f95b5dcae7b67f52a90e99](https://github.com/discourse/discourse/commit/6fec4982d903cbb088f95b5dcae7b67f52a90e99)

The issue here is that we were only looking in the container for the widget class, which only works if it’s the only widget exported by a javascript file.

This patch allows us to look up any widget registered with that name.
