Jump to content
gsgriffin

event trigger for after page load AND ALL CASCADING FIELDS FINISHED UPDATING

Recommended Posts

Not finding what I need.  I need to wait for form datapage to finish loading all of the cascading text fields before running the script.  I have a lot of cascading fields, so I cannot simply rely upon a trigger to fire onchange for the cascading field.  Does Caspio have any event trigger that can confirm all loads are finished for all cascading fields?  When loading, it should know how many fields are async getting information and it is waiting for a reply to update those fields.  Would be great to have an event listener that can tell me ALL CASCADING FIELDS ARE DONE UPDATING. 

FYI...DataPageReady listener DOES NOT wait for cascading fields.  It fires as soon as the initial HTML is loaded.  Cascading is async and can be completed several seconds (or more) as the page is "fully loaded".

Please do not suggest a timer to wait for a few seconds.  That doesn't work well, is poor programming, doesn't take into consideration different processor, browser, and internet access speeds and can cause people to wait for 10 second for a page load....the worst! I believe this will have to be a Caspio event listener.  Just can't find it in docs.

Share this post


Link to post
Share on other sites

You can add Event listener to the last cascading element.  The event should on change or value not null. this event listener should in Data Page Ready inside.

 


For Example


<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
  	if(document.querySelector("#Value3_1_5021039762ca9d"){
           document.querySelector("#Value3_1_5021039762ca9d").addEventListener("change", function(){
          		if(document.querySelector("#Value3_1_5021039762ca9d").innerText!="No options Avaliable"){
                  	//do something
      			 }		
        	});
        }
       
});
</script>

 

Share this post


Link to post
Share on other sites

For clarification....code should execute immediately after the page is completely done loading and all cascading fields have finished the initial loading.  My case scenario is a page that receives an external value that is passed to a hidden virtual field.  That hidden virtual field is the cascading dependency that many other cascading fields are waiting to change upon.  They are all hidden, but provide the values I need for my script to act upon.  I need to wait for all of the cascading fields to have completely loaded and then begin execution.  There are a lot of variables in download speeds, that I have experienced, that can change the time it takes. 

It could be me, but the cascading fields don't always seem to update in order.  Don't know if there are variables in connection speed or size of the request and database speed.  Everything is always sequential?

Especially when you have cascading drop-downs and different lengths and lots of them.  I was hoping that there might be a Caspio event trigger that might be made available to tell us that there is no more loading of anything at the initial page load.  I do realize that cascading can change and force a change to a field later, but the initial load, initial cascade completion is what I'm looking for.

Your code is fine if there is a guaranteed change on load.  If there is no cascading change, then it is not going to trigger.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...