I’m a bit confused about view startup events. They trigger properly when a page is first loaded, but don’t when navigating to the same page with different url parameters.
example: let’s say I have a view on
/foo/bar will trigger the startup script, but if I try to go to
/foo/baz from there, the script won’t re trigger.
I expect this is because the actual view is not reloaded, but I need to find a way around this.
Here’s my use case:
I have a dock that displays things related to devices. I need to pass what device is being displayed on the main page.
So, when navigating to
/foo/bar, I need to update those parameters so the dock know what to look at.
I wanted to avoid using
session.custom properties, but do I have an alternative here ?
I there are none, how do I handle multiple tabs opened on different devices ?
version is 8.1.18
You could use messaging and the session scope.
Send messages when navigating to baz / bar and have the main page handle the session scope message.
There’s a problem with this though: It doesn’t work when the user changes the url manually.
Which is why I initially used view startup scripts.
edit: I guess I could put an on change script on the main view parameters ?
The only way to force a View’s startup script is to completely remove the View from the page, and then put the View back onto the page.
Yes that’s what I figured.
But how do I pass my new parameters to the docks ?
Is there a better way than using a change script on the main view parameters to send a message to the dock ?
Would this script trigger on initial page load (is the first parameters assignment considered a value change ?)
Before 8.1.19, your only options were to either use message handlers or session properties because docked view params were static. As part of 8.1.19 we added a new Perspective package function
system.perspective.alterDock, which allows for re-configuring all parts of a Docked View at runtime - including the parameters.
The issue is actually finding the trigger for sending the message, not sending it.
I’m guessing the issue would be the same if I had access to
- I can’t use a start up script because it just doesn’t work if the view doesn’t change,
- I can’t use click events because I want it to work when someone enters the url manually,
All I can think of is using an on change script on my main view’s parameters, but that looks a bit ugly to me. So I’m wondering if there’s anything else that I didn’t think of and that I could use as a trigger for sending messages.
I’m curious why you think this looks ugly? I mean, you’re concern here is that the parameters are changing, right?
I don’t think there is another way.
I do think a change script on the Primary View’s parameters is the way to go.
I’m not a fan of on change scripts in general, but I guess I’ll walk that road this time.