Page 1 of 1

RenderRegionAsync with same scroll position

PostPosted: 20 Oct 2015 13:01
by George
Hello!

I'm interesting is there a predefined feature to RenderRegionAsync that was rendered and scrolled previously, but without position loss? My tricky approach not work anymore with chrome, since it was updated.

Re: RenderRegionAsync with same scroll position

PostPosted: 21 Oct 2015 09:40
by Alexander Bulei
Hi George,

Don't sure if it will work, but you can try:

On event with AjaxReRender add browser parameter and save the current position of scroll, then on AjaxReRender, you have 3rd parameter AAfterLazyLoadJS, add the javascript code to scroll to saved scroll position.

Best Regards.

Re: RenderRegionAsync with same scroll position

PostPosted: 06 Nov 2015 12:49
by George
Hello!

This not work and problem stands inside IW code.
I know 2 options to execute custom JS from CG code after rendering.
  • with rramOldMethod: CGAddJavaScriptToAjaxResponse()
  • with rramLazyLoad: AAfterLazyLoadJS
Both ways executes custom JS too early, when page is not rendered fully.
Since i use rramOldMethod with CGAddJavaScriptToAjaxResponse, i dived into source and found that you use IWApp.CallbackResponse.AddJavaScriptToExecute. (you may use AddJavaScriptToExecuteAsCDATA instead of adding tags manually).
So, when this code will be executed is totally depends on IW code.
I tried add "debugger;" JS code and check when it will be executed.
And you know what? Looks like it executes when dom is not rendered completely, it's impossible to scroll at correct position.

When executes custom JS,
Few steps next (almost ready)
One step next (finally dom is ready)

Only way to execute JS from CGAddJavaScriptToAjaxResponse at moment when dom is ready - use setTimeout which will sometimes work and sometimes not (on slow PC), in addition user will see how page scrolls down which is not cool at all(

i don't like setTimeout and don't know how to be.
Probably i have to carefully patch IW source once more or find other solution.
Future IW update becomes more and more hard task.

Maybe you can discuss this issue with Alexandre?

Re: RenderRegionAsync with same scroll position

PostPosted: 06 Nov 2015 14:20
by George
I'll try to make simple demo.

Re: RenderRegionAsync with same scroll position

PostPosted: 27 Jun 2017 03:47
by bryl
I have the same issue, is there a demo?

Re: RenderRegionAsync with same scroll position

PostPosted: 29 Jun 2017 12:16
by Alexander Bulei
Hi bryl,

To do that, you need use the AjaxRender with 3 parameters:

delphi code
IWCGJQGoogleAutoComplete1.AjaxReRender(True, rramLazyLoad, '<your_js_script_here>');


But before, you need save the scroll position to some global variable (via javascript), and then of 3rd parameter of AjaxReRender, use that var to restore the scroll position.

Best Regards.