0

I got this error when using uniGUI framework for executing JS code.

Cannot read property 'scrollView' of undefined

This property is used in this procedure.

procedure SetScrollboxSize(AFramem: TWPUnimFrame; ASize: Integer);
begin
  if ASize > AFramem.ScrollBoxm.ClientHeight then
    UniSession.JSCode(AFramem.Scrollboxm.JSName
                      + '.scrollableBehavior.scrollView.getScroller().maxPosition.y = '
                      + (ASize - AFramem.Scrollboxm.ClientHeight).ToString + ';')
  else
    UniSession.JSCode(AFramem.Scrollboxm.JSName
                      + '.scrollableBehavior.scrollView.getScroller().maxPosition.y = 0;');
end;

Can you give me a hint where to search or where to start to fix this bug?

Triber
  • 1,525
  • 2
  • 21
  • 38
Josef Henn
  • 125
  • 4
  • 18
  • I think this needs a [mcve] – J... Feb 26 '19 at 12:39
  • 1
    I see that the question is updated and probably this component set is based on Sencha Touch 2.3.1. Again, try to change your JavaScript code or read the docs about [Ext.Container.getScrollable](https://docs.sencha.com/touch/2.3.1/#!/api/Ext.Container-method-getScrollable). – Zhorov Feb 27 '19 at 13:50

1 Answers1

0

It's difficult to reproduce your error without the actual source code, but "Cannot read property '...' of undefined" is typical JavaScript error. I guess that TWPUnimFrame is some kind of component for displaying web content.

In your case you need to make sure that AFramem.Scrollboxm.JSName + '.scrollableBehavior' variable is assigned. You may try to output some information with console.log() and debug JavaScript code:

procedure SetScrollboxSize(AFramem: TWPUnimFrame; ASize: Integer);
var
    code: string;
begin
    code := 'console.log(' + AFramem.Scrollboxm.JSName + 'scrollableBehavior.scrollView); ';
    if ASize > AFramem.ScrollBoxm.ClientHeight then
        code := code +
            AFramem.Scrollboxm.JSName + 
            '.scrollableBehavior.scrollView.getScroller().maxPosition.y = ' +
            (ASize - AFramem.Scrollboxm.ClientHeight).ToString + ';'
    else
        code := code +
            AFramem.Scrollboxm.JSName +
            '.scrollableBehavior.scrollView.getScroller().maxPosition.y = 0;';
    UniSession.JSCode(code);
end;
Zhorov
  • 28,486
  • 6
  • 27
  • 52
  • This question is tagged Delphi, not Javascript. – Ken White Feb 26 '19 at 18:24
  • 1
    @KenWhite Yes, but if I understand the question correctly, OP tries to execute JavaScript code. Thanks for this note, I didn't notice that `JavaScript` tag is missing. – Zhorov Feb 26 '19 at 18:32