When utilizing the content API syntax is key

With dominKnow | ONE you can access a variety of functions through the contentAPI and utilize them in your HTML widgets. When using them them, syntax is key.

The basic format can be seen below:

For getting and setting variables

//Where thevariablename is the name of a custom variable declared in your dominKnow | ONE project.
parent.contentApi.getData('thevariablename');

//Where tempVar is a JavasScript value to which you are setting the dominKnow | ONE variable.
parent.contentApi.setData('thevariablename',tempVar);


Calling a contentAPI action that gets the studentID

//Where studentID is the name of a custom variable declared in your dominKnow | ONE project.
var studentID = parent.contentApi.getUserID ();

Calling a contentAPI action that gets the studentName

//Where studentName is the name of a custom variable declared in your dominKnow | ONE project.
var studentName = parent.contentApi.getStudentName ();


General JavaScript Hints

It's often useful to see what is going on in a script. You can send information to the Browser's log (which you can see in advanced settings - JavaScript Console) so you know if the script is working.

For example in the studentName case you could report the value to the console log when testing with the following JavaScript command.

console.log ("student is " + studentName);

DISCLAIMER: The dominKnow support team does NOT provide programming/coding support for the creation of CSS and JavaScript elements when creating your dominKnow | ONE content.

  0     0

Similar Projects

Questions  ( 2 )

  • 0
     Asked 3 months ago    ayrus123      0   |   2  
    How to pass a score value to the LMS using content API
  • 0
     Asked 3 months ago    ayrus123   Edited3 months ago    0   |   2  
    Thanks Paul Schneider, it really helps. But now i was able to pass the value to the LMS iam using the below code"var lmsAPI = parent; var scoreSCQ = parent.contentApi.getData('MQ_Score'); lmsAPI.SetScore(scoreSCQ, 100, 0);" but the problem is the score was passing to LMS successfully when viewed through desktop but not working when viewed through mobile devices. Any idea why it is working in mobile
      Answers ( 1 )

    • 0
       Answered 3 months ago    Paul Schneider      502   |   8  
      The problem is most likely due to the fact that framesets will change from device to device and LMS to LMS.

      So you are looking to launch/trigger the function from one of these framesets (for example)
      top
      Parent
      Window
      Parent.window
      Parent.parent
      Top.window

      You can use the debugger tools in Safari on Mac by connecting an iOS device to the mac and enabling it to help discover this and test it out via the debugger tools.

      FYI dominKnow support doesn't provide formally support for writing JS and CSS code.

      You may also wish to join one of our community meetings as there are a number of very talented customers that regularly join them and may be able to assist: https://dki.io/2329ed14