JavaScript event from AJAX Refresh

JavaScript event from AJAX Refresh

  

Hello, I was wondering, is there a proper way (using OutSystems 10 web apps, on premise, .NET) to have our client side javascript receive an event when any ajax response has been received on the client for any refreshed contents (from Ajax Refresh on Ajax submit action).
I suppose there must be some client side OutSystems (if not ASP.NET) event to hook into?
(Our own javascript is part of one generic web block used on many pages, which should update some things client side whenever any other web blocks or content blocks are refreshed after Ajax submit.)

Thank you very much

Hi Ahron,

I am unable to understand you use case can you please explain in more detail.

Regards

-SK-

Hi Shashi

Our use case: we are working on a web project with 100+ pages all being different input forms allowing a user to input query parameters (report filter values) for a report, the results of which are presented in a standard grid component.

Now we have two more special requirements: it is required that any filled-in form can be saved by the user as a kind of preset query definition, allowing the user to quickly retrieve the query parameters back in the form; and also to mark that report definition to be run scheduled in a batch process which is to generate PDF or Excel reports (i.e. outside the context of the input screen) and mail these to the client.
For these two special requirements we have a generic implementation, based on a client side javascript (present via one standard web block in every page) that is listening to any changes in the inputs in the page and creating a JSON string containing all input (filter) values. That JSON is thus continuously synchronised (on any input change) with the input values, and the JSON result is made available in a hidden input in the generic web block for further server side use. 

This is all working fine with the standard Outsystems inputs (text, checkboxes, radio buttons, date picker). However a substantial number of inputs are coupled to popup helpers, that place a value in the input via popup notification and ajax refresh of the related input. Such changes in the input value do not yield a client side event on change (as it is not a client side user change but an AJAX partial reload of the input container).

So my question is whether in JavaScript we can register an event listener that fires after any Outsystems AJAX refresh has been made to the page client side, so our java script can update the JSON string to reflect the changed input value(s) resulting from the AJAX response. (For us it is not important to know what contents have been updated, only when something where ever is updated).
I imagine such is available as such must also be used for the standard Outsystems implementation of the  "loading" indication (spinner), and perhaps for standard Outsystems call backs for performance measurement.

Thank you very much for your collaboration (and sorry for my late, and perhaps elaborate, reply), greetings Ahron.

Solution

Hey Ahron,

Try this:

$(document).ready(function(){
            osAjaxBackend.BindAfterAjaxRequest(function(){alert('AJAX refresh')});
    });


Hope it helps

Solution

Thank you very much Henrique, that is the solution we were looking for, it works. Regards, Ahron.

Ahron de Leeuw wrote:

Thank you very much Henrique, that is the solution we were looking for, it works. Regards, Ahron.

No worries, happy to help!

Cheers