Hello,
I'm trying to get the client web browser to scroll to the top of the screen whenever I switch tabs using my dashboard.
I've tried wiring an ui_control node to an ui_template node with javascript code in it to do so, as follows :
[
{
"id": "a019318ae7b010fb",
"type": "ui_template",
"z": "4f586e426698d29e",
"group": "0f6b52040957d536",
"name": "Scroll top",
"order": 30,
"width": 0,
"height": 0,
"format": "<html>\n<body>\n <script>\n (function(scope) {\n // $watch fires each time the node is triggered in the flow\n scope.$watch('msg', function(msg) {\n window.scrollTo(0,0);\n document.body.scrollTop = document.documentElement.scrollTop = 0;\n window.scrollTop(0);\n });\n })(scope);\n </script>\n</body>\n</html>",
"storeOutMessages": false,
"fwdInMessages": false,
"resendOnRefresh": false,
"templateScope": "local",
"className": "",
"x": 420,
"y": 800,
"wires": [
[]
]
},
{
"id": "d81424dca2bec936",
"type": "ui_ui_control",
"z": "4f586e426698d29e",
"name": "",
"events": "all",
"x": 260,
"y": 800,
"wires": [
[
"a019318ae7b010fb",
"f1d057390698d082"
]
]
},
{
"id": "0f6b52040957d536",
"type": "ui_group",
"name": "Domoterre",
"tab": "f1e2ad2b41fe03c5",
"order": 1,
"disp": false,
"width": 6,
"collapse": false,
"className": "<style> body {background-image: url(\"/img/Face-normal.png\");}</style>"
},
{
"id": "f1e2ad2b41fe03c5",
"type": "ui_tab",
"name": "Accueil",
"icon": "home",
"order": 1,
"disabled": false,
"hidden": true
}
]
But it doesn't work...
Any clue what I might be doing wrong? Could it be an issue of the web page not being fully loaded when the script is executed, hence not working properly?
Thanks a lot !