# How to refresh topic title when it was changed in one of plugin's custom controllers

**URL:** https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480
**Category:** Development
**Created:** [March 19, 2017, 12:44pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480 "2017-03-19T12:44:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [March 19, 2017, 12:44pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480/1 "2017-03-19T12:44:40Z")

</div>

I update topic using custom controller where function was triggered through ajax. Client side code gets back result with a changed topic title but I’m unable to figure out how to refresh topic title in topic-view inside “then” callback. Strangely the archieved property change will call archieved “lock” icon to show up. Title will change only in page title but not in topic main title.

```
export default {
  actions: {
    clickSoldButton(topic) {
      ajax("/topic/sold", {
        type: "PUT",
        data: {
          topic_id: topic.id
        }
      }).then((result) => {
        topic.set('custom_fields.sold_at', result.topic.sold_at);
        topic.set('title', result.topic.title);
        topic.set('archived', result.topic.archived);
      }).catch(() => {
        bootbox.alert(I18n.t('topic_trading.error_while_marked_as_sold'));
      });
    }
  }
};

```

Is there a certain way to get Title to change other than navigating to topic or page reload?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 19, 2017, 2:12pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480/2 "2017-03-19T14:12:37Z")

</div>

There is a new event for this you can use after

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

`this.appEvents.trigger('header:update-topic', topic);`

Also, if you properly use `PostRevisor` this is handled automatically for you.

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [March 19, 2017, 2:41pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480/3 "2017-03-19T14:41:15Z")

</div>

Thank you. But I can’t use PostRevisor as I want topic to be updated even when it’s not editable by user. As I understand, revisor will go through Topic.update which prevents changes after editing time has passed?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 19, 2017, 2:42pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480/4 "2017-03-19T14:42:05Z")

</div>

Not really a problem, cause you can disable validations when you update if you wish via the api (or perform the edit as system)

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [March 19, 2017, 2:43pm UTC](https://meta.discourse.org/t/how-to-refresh-topic-title-when-it-was-changed-in-one-of-plugins-custom-controllers/59480/5 "2017-03-19T14:43:00Z")

</div>

Ok. I’ll give it a try. Thanks!
