HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... how to call object methods from javascript?
how to call object methods from javascript?
  View type:
Hi all,
thanks for your very nice elearning IDE!
I have the following question:
how to call object methods in JAVASCRIPT action?
for instance I would call Show() and Hide() methods of the Agent object.

Thank you
Angelo
 
Hi,
Can someone help me please?

Thanks
 
 
Hi, Angelo,

It is not an easy way.

You can try:

CallMethod(sType, sMethod, oArg)

sType - string, that corresponds object type (usually object's file/folder name, for example "nav_001_selector")

sMethod - string, method name (not pretty name used in dialog! real name)

oArg - object, contains at least one parameter oArg.pid = object ID, and also all other parameters of method.

But it is all at your own risk - in fact there are a lot of checks before methods call. Especially for Agents...
 
 
 
Hi Slav,
Thank you very much for your answer.

I made a small javascript code for hide my agent and all work fine[:D]

Here a example for CourseLab community:

var a = new Object;
a.pid = 'OBJ_19'
CallMethod("agent_001", "HideAgent",a);

I found the real name object in runtime.xml file.

Slav,
I have another question for you:
could you provide same code to set method parameters?

I like programming and with last request I will can completely program my course via javascript.

Thank you
Angelo
Subject:
Message options
No additional options