Hi Pet3Art
The best way to ensure that your javascript only fires after the entire formview has been loaded and rendered would be to make use of a Timer Control in the viewform.
On your view or form, preform the following steps to add in a delay for when the javascript should fire.
Note: You can specify how long the delay should be by altering the interval on the timer control, keep in mind that the interval is specified in milliseconds. See the Timer Control Documentaion for more detail: https://help.k2.com/onlinehelp/k2five/userguide/5.0/default.htm#Create/K2Designer/Controls/Timer/TimerControl.htm
Steps:
1) Add a Data Label and ensure that its Literal property is enabled (Checked)
2) Add a Timer control anywhere ont he viewforms design canvas.
2) On the viewforms initialize, call the Timer Start Method using the "Execute a control Method" Action Rule.
3) Set the Timer to a specified time that you have predetermined would be enough.
4) Add a new rule using "When a control on the viewform raises an event", specify that the control should point to the Timer control and the Event should be the "Ticked" event. Then add a Transfer Data rule.
6) In the transfer data rule, add your code to the data label we added in step 1
7) Save, Finish and Run the ViewForm.
Result:
When the viewform is run, the timer will start which means that the timer will start counting the milliseconds that had been specified, once it reaches the amout that was spcified, the Timer Ticked event will trigger which would fire the transfer data rule inevitably firing the code contained in the transfer data rule by passing it to the data label.
Should you feel that this post is of use and or an accurate solution to the raised question, I kindly encourage you to mark it as such using the 'Mark as Solution', 'Kudo' andor ‘Me Too’ options.
Kind Regards
Raymond