Ignition Perspective - run script on page refresh

Where can I put code to clear text fields when user refreshes page?

Thanks.

You can use the onStartup event on the view components.

I have tried several iterations and it does not handle it. I have a Main Menu View page that it defaults to on a refresh and when the user clicks the button to navigate to the next View, it does not actuate the “onStartup” code. If I start the webpage new, it works correctly, but does not act the same on page refresh.

Hello, Do you have find a solution for this ?
Thanks

1 Like

Hello, Do you have find a solution for this ?
Thanks

Hey David/anthony/victor,

Did you get any solution related to refresh button?

Thank you

Hey David/Anthony/Victor/Abhishek,

Did you find any solution or workaround to this?

Thanks

When the page is refreshed the components are restarted.

I don't think that is accurate. Those events don't fire on refresh. Please correct me if I'm wrong.

1 Like

You're right! My testing was incomplete.
Thanks.

Is there anyone with more details on this issue, because when I create a text field (without any binding), I input text in it, I refresh, and I no longer have a value.

If I use a binding with a local custom property, I still don't have any issues.

Issues appear when using session properties, and in our case, we try to avoid those as much as possible

Components refresh their values / bindings when you refresh the page. But in my case, I would like to run a script when users refresh the page. There is no such event available, and the "on startup" event is triggered only once when the session starts. This issue has been brought up multiple times but the developer chose not to implement a solution because of the complexity involved in handling browser connections. So I am looking for a feasible workaround for this.

so you said "Component refresh their binding on refresh", so you can just have a expression binding with now(0), add a script as a transform, and do whatever you want in it right?

I don't think components refresh either. Drop a label with expression now(0) on the text prop. The time doesn't update when you hit refresh.

2 Likes

After testing it out and as @jlandwerlen said, I might be wrong, components don't refresh their bindings

do you disable persistent property?

Do you disable persistent property?

Persistent = false doesn't work either. Did you try it?

Initial question was to find a way to clear text field, which I can't reproduce as when I refresh, text field are cleared, and people are asking if OP found a solution to his problem.

This is why I asked a bit more details on the goal people want to achieve.

I have a view with two Text Field components on it (and a label).

  • In Designer one is blank and one has some text.
  • On both, props.text has Persistent = false.
  • When the page first loads both are empty.
  • If I type text into both, shift the focus onto a label (or press Enter to commit) and then refresh the page the text that I've just entered reappears.

Can you post the JSON of a Text Field component that clears when the page is refreshed in the browser?

with this case, I got couple issue, but using session event, on page startup, you will have a script that run on refresh, but not 100% certain you will be able to do what you want