Skip to main content
Nintex Community Menu Bar

Execute JS after view load

  • June 19, 2017
  • 5 replies
  • 178 views
  • Translate

Forum|alt.badge.img+7

Hi Everyone,

 

Anyone had success with running JS after a view has loaded? I have been trying with several approaches all with no luck. I have tried window).load, $(document).ready. I've tried using the Initialised rule and tranfering expressions using data tranfer. Doesn;t matter which approach I use the JS will always fire before the data from view has loaded. I need to fire after becuase I want use a selector on a list view. Thanks in advance

Did this topic help you find an answer to your question?

5 replies

Albarghouthy
Forum|alt.badge.img+16

Hi MrSafe,


 


Have you tried to transfer your script after initializing the form/view?


you have more than one event for the view (i.e. Initialize, Initialized), try to perform the transfer in the initialized event.  


 


Please post the script you're trying to execute if the above didn't help

Translate

Forum|alt.badge.img+7
  • Author
  • 28 replies
  • June 19, 2017

Hi Mustafa,

 

Thanks for the reply, I have tried the data transfer in the initialized rule. Currently I'm not trying anything fancy just an alert to see when it's firing. You can try it yourself quite quickly with a datalabel and a view. At first I thought it was because I put the Data Label in the form the view was hosted in, so I moved the label into the view. I have since come to the notion that I have to wait for the Ajax calls to finish before firing the JS, so I have tried using .ajaxStop and .ajaxComplete. Whilst these definately fire at different times, they still don't allow all list views to load before firing or it's running async and doesn;t care! The goal here is to be able to hit a view element with a selector, but if it's not loaded it does not exist at that moment and therefore fails.

 

Translate

Albarghouthy
Forum|alt.badge.img+16

Hi,


 


I understand what you mean, tbh I am not sure how to synchronize this using scripts.


I had a similar problem a while ago and I had to populate a data label after a certain call then added a rule to fire the script when the data label is changed.


 


 

Translate

Forum|alt.badge.img+7
  • Author
  • 28 replies
  • June 20, 2017

Hi Mustafa,

 

Thanks again for the brain storm,

 

I achieved what I wanted if not all together satifactorily.

 

I was trying get around the fact k2 does not support controls being displayed when not in edit mode. I have a list view of bits that render true or false when not in edit and render as check boxes when in edit mode. I wanted to make the view a bit more friendly by subsitutng the words true and false with images.

 

I had to use a setTimeout (Not great) to substitute after the form loaded, I then used 2 data transfer rules and the same JS without the onload and setTimeout wrappers in another expression, this was set to fire on the list item changed event.

 

This seems to work very well, however, I'm concerned about the settimeout not firing if the page takes longer than the setTimeout Threshold to fire.

 

Thanks again

Translate

Forum|alt.badge.img+4

Hi,

 

Their discussion solved my same issue after transferring JS at runtime to datalable at runtime.

 

Regards,

Asad Naeem

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings