Skip to content

Executing scripts in stimulus in html-button-response #3206

Answered by Shaobin-Jiang
Yi-fengyu asked this question in Q&A
Discussion options

You must be logged in to vote

I should think not, as that is specified by HTML:

script elements inserted using innerHTML do not execute when they are inserted

But you do not really need external-html. I mean, external html is generally for cases where seriously complex html is needed. But for a simple case like what you have described, you can simply set the basic html in stimulus and add whatever interactive function you might want in on_load.

Here's a simplified example:

let trial = {
  type: jsPsychHtmlKeyboardResponse,
  stimulus:
    '<p id="target">1</p>' +
    '<input type="button" id="button-1" value="1">' +
    '<input type="button" id="button-2" value="2">' +
    '<input type="button" id="button-3" value="…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Yi-fengyu
Comment options

Answer selected by Yi-fengyu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants