evalCommand("a= Slider(0, 1)") not working in offline embedded applet

rbrinkmann shared this question 4 years ago
Answered

Hi,

thanks for all the great work you do!


When I open the attached file in chrome, the circle is added to the applet but the slider is not.


(screenshot01.png)

However executing:

ggbApplet.evalCommand("a=Slider(0,2)");

in the browser console directly, will add the slider.

(screenshot02.png)


Changing

ggbApplet.evalCommand("a=Slider(0,2)");

to:

ggbApplet.evalCommand("a=1");

in index.html will only produce a default slider.


What'S the correct way to add a custome slider to an embedded applet?

Comments (9)

photo
1

You have to use the correct GGb-command-syntax for slider:

ggbApplet.evalCommand('a=Slider(0,5,0.1,1,250,false,true,false,false)')

photo
1

Still doesn't work for me. I tried this in Chrome, Firefox and Edge.

using this line:

retVal = ggbApplet.evalCommand('a=Slider(0,5,0.1,1,250,false,true,false,false)');

in my index.html file will return false.

when entering the line in the browser console it returns true and adds the slider.

photo
1

Ok after running a test with your index.html file i can confirm that it will not create slider by the slider-command.

I tried to get the command of slider a after generating it manually with ggbApplet.getCommandString('a') and it returns "".

And by adding the parameters "showLogging": true, you can see: Command not loaded yet which might give you the hint that "appletOnLoad" might not be the right place to script yet?

photo
photo
1

---

photo
1

Try ggbApplet.evalCommand('a=Slider(0,5,0.1,1,250,false,true,false,false)') retVal=

photo
1

Use the JS command asyncEvalCommand(). Not sure though if it is the right way to script the applet at startup and not load it with ggbBase64 or material_id (Reference:GeoGebra Apps Embedding).

photo
1

Yes, that's it!

Probably, the prefered way is to load an existing file or material.

Since asyncEvalCommand is not mentioned in the reference, one can only guess.

For me it works!


Thanks!


- not sure how to mark this as answered -

photo
1

it is mentioned in the log while using "showLogging": true

photo
photo
1

The bug with evalCommand() is fixed, please try now


Please don't use asyncEvalCommand(), that's experimental and will probably be removed soon

© 2023 International GeoGebra Institute