RTO_visible_when_tab.js

Helper file documentation for RTO_visible_when_tab.js.
Docs updated: 2026-03-24

Summary

Show/hide elements depending on whether a tabKey is open.

  • Exports: RTOVisibleWhenTab (bind(), rescan())
  • Depends on: RTO_tabsList.js (which depends on RTO_form_api.js)
  • Recommended: RTO_connector.js (sets window.RTOconnected)

What it is

A tiny UI helper that toggles elements based on tab state. Typical use: show a panel only when a given tabKey is currently open (controlled by RTO).

Internally, it uses the current tabs snapshot when available and falls back to a real listTabs request when needed.

Download

Download RTO_visible_when_tab.js

Data attributes

  • data-rto-visible-when: tab-open
  • data-rto-visible-tabKey: the tabKey to watch

Example

<div
  data-rto-visible-when="tab-open"
  data-rto-visible-tabKey="billing"
  style="display:none"
>
  Billing tab is open ✅
</div>

<script src="../RTO_helpers/RTO_form_api.js"></script>
<script src="../RTO_helpers/RTO_connector.js"></script>
<script src="../RTO_helpers/RTO_tabsList.js"></script>
<script src="../RTO_helpers/RTO_visible_when_tab.js"></script>
<script>
RTOconnectOnce(1500).then(function(){
  RTOVisibleWhenTab.rescan();
});
</script>

Next