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.

//Where tempVar is a JavasScript value to which you are setting the dominKnow | ONE variable.

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 ();

//NOTE: If you are calling functions from the Execute JavaScript panel you are "one" frame above an HTML widget so the syntax would be:


//instead of 


//drop the "parent" from the call.

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 2 years ago    ayrus123      0   |   3  
    How to pass a score value to the LMS using content API
  • 0
     Asked 2 years ago    ayrus123   Edited2 years ago    0   |   3  
    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 2 years ago    Paul Schneider      753   |   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)

      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