# Auto refresh dashboard when changing tabs

**URL:** <https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515>\
**Category:** Dashboard\
**Created:** [19 April 2022 21:21 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515 "2022-04-19T21:21:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [19 April 2022 21:21 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/1 "2022-04-19T21:21:45Z")

</div>

Hi,

I have created 2 "google home alarm clock" dashboard flows  
one for me and one for my daughter. We view the dashboard on android mobil phones.

When I switch between the 2 TABs, the saved (to file) context data is only loaded into the dashboard when I refresh the page (swipe down)

How can I auto refresh when switching to the other TAB?

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 April 2022 23:04 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/2 "2022-04-19T23:04:20Z")

</div>

Use the ui\_control node as trigger

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d5d4ed49fa487727c81a1db57234060c1d85a6f.png)

and send to another ui\_control the payload with an empty tab name to refresh the current page.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/151b25045660360b6aee69738d2001d6ccd46de4.png)

---

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [20 April 2022 21:28 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/3 "2022-04-20T21:28:11Z")

</div>

Hi, i have connected the nodes like this in both flows, but nothing happens when I change tabs.

 ![20220420_230954](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35bc460b5ed4b4e825a58fdeda145388984dfca3.jpeg)

When the dashboard is loaded from scratch in the (chrome) browser, the context data is loaded into the first tab, but when I switch tabs I need to refresh each time

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [20 April 2022 23:25 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/4 "2022-04-20T23:25:42Z")

</div>

You have to take care that you create no endless loops - because a refresh triggers the first node again. So it is useful to filter out the tab which should be refreshed and you need to delete the socket-id.

So i created a flow which refreshes a page "test" when someone switches a tab named test.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba27bbf3307c86a5be2010d5a2adfefa39bba556.png)

```auto
[
    {
        "id": "5ea0c06fa7709de5",
        "type": "ui_ui_control",
        "z": "54b226bc.0793e8",
        "name": "",
        "events": "all",
        "x": 180,
        "y": 3080,
        "wires": [
            [
                "7d9c29f0419c67fe"
            ]
        ]
    },
    {
        "id": "12d1e9659b28dc8c",
        "type": "ui_ui_control",
        "z": "54b226bc.0793e8",
        "name": "",
        "events": "all",
        "x": 860,
        "y": 3080,
        "wires": [
            []
        ]
    },
    {
        "id": "a7e09627253fb76a",
        "type": "change",
        "z": "54b226bc.0793e8",
        "name": "Refresh Browser",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"tab\":\"\"}",
                "tot": "json"
            },
            {
                "t": "delete",
                "p": "socketid",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 3080,
        "wires": [
            [
                "de960b742c49b829"
            ]
        ]
    },
    {
        "id": "7d9c29f0419c67fe",
        "type": "switch",
        "z": "54b226bc.0793e8",
        "name": "",
        "property": "name",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "test",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 330,
        "y": 3080,
        "wires": [
            [
                "a7e09627253fb76a"
            ]
        ]
    },
    {
        "id": "de960b742c49b829",
        "type": "trigger",
        "z": "54b226bc.0793e8",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "nul",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 700,
        "y": 3080,
        "wires": [
            [
                "12d1e9659b28dc8c"
            ]
        ]
    }
]

```

You have to think if you really just want to refresh a page/tab or if a flow should be triggered again to fill i.e. template nodes again.

So I fill my template nodes each time - my tab is selected again. The change tab event triggerst again the flow to fill the template nodes again - this is not a refresh tab - it is a refresh of the template nodes.

---

<div class="post-metadata">

**Author:** ![gschmidt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gschmidt/32/60349_2.png) [@gschmidt](https://discourse.nodered.org/u/gschmidt)\
**Post date:** [22 April 2022 16:14 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/5 "2022-04-22T16:14:21Z")

</div>

Thanx…this is working.  
I guess I only have refresh the nodes of the second tab (which is my Google Home Alarm Clock), because the nodes of the first tab (my daughters Google Home Alarm Clock) are always refreshed when the chrome page is opened?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 May 2022 16:15 UTC](https://discourse.nodered.org/t/auto-refresh-dashboard-when-changing-tabs/61515/6 "2022-05-22T16:15:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
