Good question. In technical terms this is called “view binding” or “one-way binding”. If a value of a variable changes, update it in the corresponding element that’s being viewed. (As opposed to two-way binding, where if a view is updated, the corresponding variable (model) is updated as well) Currently one-way binding is not supported in the QRTEngine, so your best bet would be to build your own JS/HTML solution. The trick would be to use a combination of HTML and JS to update your value upon showing the stimulus, the simplest form would be the following:
In your HTML View, add an element with a specific ID (important!). For example:
The onShowFn in the Stimulus JS is a function that gets called upon the stimulus being shown (or rather, right before its shown). This would be the ideal place to put a bit a code that changes the innerHTML of the HTML element we just defined.
We can target the element as defined above, with the JS defined below:
$('CustomElement').innerHTML = 'testtext';
This would change the contents of the HTML element to ‘testtext’.
Instead of using the ‘testtext’ as, you want to use the RT instead. Which would be the following:
$('CustomElement').innerHTML = QRTE.getTrialData(“PressKey[RT]”);
If placed in the correct question, this should update the content of our CustomElmement to the RT of the PressKey stimulus.
Hope this helps!