Any way to trap the Scriptcase ajax refresh event on a grid?

Thats the event that triggers when you see the message ‘Processing’, with a small rotating circle.

When SC navigates on a grid, or you select additional lines from the lines per page box, it triggers a grid refresh using an ajax/javascript function, rather than any formal grid refresh.

Because of this , things like the on-Navigate event don’t allow you to use jQuery or javascript(It says so in the manual and I can confirm this is correct).

It means that some jQuery I use for DOM manipulation (I can’t use css for what I need before you ask), only works on the first page and I can’t find a way to repeat it during the ajax refresh. I’ve tried the code in EVERY event including onRecord!

It seems like I need to find a way to trigger it from the ajax refresh.

Has anyone found or solved this problem, or has any ideas?

I don’t have SC handy now, but if I remember correctly I do that by creating a button of type link.

I then set the js function I want to trigger as the button label.
Eg:

<script>run_form_header_set();</script>

As that label is not visible the button will not be visible (not sure if with any ccs style, but there are some css styles that will make the button invisible for sure) but it will be rerendered at any Ajax event, thus retriggering the function.

Many thanks… yes that seems to work (at least with a simple test function created in onAppInit).

echo('<script>function run_form_header_set(){
alert("Navigated");
}</script>');

I’ll need to reconstitute my original code as it is a mix of PHP and Javascript doing some loops, etc. But I think this is the nub of my solution.

not sure what you’re doing, but note also that if you want js code triggered per each record, you can add (as text) the js function call to a field that is set to execute embedded js code.

if the function has to contain some parameters that are specific per record, you can output the function text into the field in the onrecord event

the function will be retriggered even during ajax refresh, as long as the grid shows some records.

this hack can be very heavy on the client, as the function is triggered per each and every record

Yes thanks, I’d thought of using a field on the onRecord, but didn’t want multiple calls as its already a fairly heavy app . Your main solution is the best for what I need… though I’m struggling with the Javascript as I don’t often use it. I’ll get therre in the end!