# 全チャットページと個別チャットページへの手動遷移トリガー

**URL:** https://meta.discourse.org/t/manually-trigger-navigation-to-all-chat-page-and-also-to-single-user-chat-page/317012
**Category:** Development
**Tags:** chat
**Created:** [2024 年 7 月 18 日午前 11:17 UTC](https://meta.discourse.org/t/manually-trigger-navigation-to-all-chat-page-and-also-to-single-user-chat-page/317012 "2024-07-18T11:17:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![robertkibet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robertkibet/32/290055_2.png) [@robertkibet](https://meta.discourse.org/u/robertkibet)
#### Post date: [2024 年 7 月 18 日午前 11:17 UTC](https://meta.discourse.org/t/manually-trigger-navigation-to-all-chat-page-and-also-to-single-user-chat-page/317012/1 "2024-07-18T11:17:23Z")

</div>

こんにちは、ユーザーチャットに手動で移動するにはどうすればよいですか？

ユーザーページに表示されるカスタムユーザーリストがあり、このスクリーンショットのチャットボタンと同様に、そのユーザーチャットページへの移動をトリガーするチャットボタンをアタッチしたいと考えています。

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/4/0/d4018542373667c2a476e3fe649e73debe9ce5ca.png)

このコールバックをボタンにアタッチしようとしましたが、

```js
customChatButton.addEventListener('click', () => {
    window.Discourse.router.transitionTo(`/chat/c/${username}`)
});

```

「ページが存在しないか、プライベートです」というメッセージが表示されます。

また、そのユーザーテーブルにはカスタムの「すべてのチャット」ボタンがあり、ユーザーがそれをクリックしたときに、画面右下からチャットポップアップをトリガーするのではなく、全画面で「すべてのチャット」ページに移動させたいと考えています。

このコマンドは機能しないようです。

```js
goToAllChatButton.addEventListener('click', () => {
    window.Discourse.router.transitionTo(`/chat`)
});

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/4/a/54a4d922c54e965d4e1d411968d09110370fc437.png)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2024 年 7 月 18 日午前 11:31 UTC](https://meta.discourse.org/t/manually-trigger-navigation-to-all-chat-page-and-also-to-single-user-chat-page/317012/2 "2024-07-18T11:31:51Z")

</div>

このコンポーネントを直接使用できます。

```plaintext
<Chat::DirectMessageButton @user={{user}} @modal={{true}} />

```

---

<div class="post-metadata">

### Author: ![robertkibet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robertkibet/32/290055_2.png) [@robertkibet](https://meta.discourse.org/u/robertkibet)
#### Post date: [2024 年 7 月 18 日午前 11:34 UTC](https://meta.discourse.org/t/manually-trigger-navigation-to-all-chat-page-and-also-to-single-user-chat-page/317012/3 "2024-07-18T11:34:55Z")

</div>

@j.jaffeux様、返信ありがとうございます。ルーターオブジェクトで直接行うことは可能でしょうか？
