I want to detect when the Dashboard 2 user changes tabs or reloads their page. In DB1 I used the ui control node successfully to do this however in DB2 I don’t get any output from the ui-control node when changing tabs.
Can anyone suggest a way around this?
I am not using the ui control and event dashboard 2 nodes for page load and page get focus, since all dashboard tabs on the same window use the same socket, and event behavior is tricky.
I use a hidden template node, which invokes a 'load' event when the page is loaded, and a 'focus' event when the user switches to the tab.
<script>
export default {
mounted() {
this.send({payload:"Page 2 loaded"});
const vThis = this; // save the base context
window.addEventListener('focus', () => {
vThis.send({payload:'Page 2 received focus'});
});
}
}
</script>
Thank you @rakgupta. I had it set to “All events” but now when I check I am getting output intermittently. It seems that the tab change event is only output when there is also a connect event.
Thanks for your reply.
With the settings I have, I get the events triggered quite reliably. I use it to start the flows on each tab to pre-populate data when the user selects a particular tab/page. I do have another ui-control node that is set to “connect events only” - this is used to populate some global variables etc. that are used across all flows.
@rakgupta We have to be careful when using the word Tab. Are you talking about multiple tabs within a single page using Tab layout, or are you talking about pages? I think that unfortunately the ui-control node uses the word tab to mean pages.
Yes, by ‘tabs’ I am referring to the means of switching between pages of the dashboard.
Now when I use the ui control node I’m seeing output as expected for ‘connect’ and ‘change’ events as expected. Earlier I was not seeing this output and I can’t identify what has changed.