jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments
Authors/Creators
Description
Major Changes
#2858
f90c0ef9Thanks @bjoluc! - - Makebutton_htmla function parameter which, given a choice's text and its index, returns the HTML string of the choice's button. If you were previously passing a string tobutton_html, like<button>%choice%</button>, you can now pass the functionfunction (choice) { return '<button class="jspsych-btn">' + choice + "</button>"; }Similarly, if you were using the array syntax, like
['<button class="a">%choice%</button>', '<button class="b">%choice%</button>', '<button class="a">%choice%</button>']an easy way to migrate your trial definition is to pass a function which accesses your array and replaces the
%choice%placeholder:function (choice, choice_index) { return ['<button class="a">%choice%</button>', '<button class="b">%choice%</button>', '<button class="a">%choice%</button>'][choice_index].replace("%choice%", choice); }From there on, you can further simplify your function. For instance, if the intention of the above example is to have alternating button classes, the
button_htmlfunction might be rewritten asfunction (choice, choice_index) { return '<button class="' + (choice_index % 2 === 0 ? "a" : "b") + '">' + choice + "</button>"; }- Simplify the button DOM structure and styling: Buttons are no longer wrapped in individual container
divs for spacing anddata-choiceattributes. Instead, each button is assigned itsdata-choiceattribute and all buttons are direct children of the button group containerdiv. The containerdiv, in turn, utilizes a flexbox layout to position the buttons.
- Simplify the button DOM structure and styling: Buttons are no longer wrapped in individual container
#3339
74b4adc7Thanks @jodeleeuw! -finishTrial()now clears the display and any timeouts set withpluginApi.setTimeout()
Minor Changes
Notes
Files
jspsych/jsPsych-@jspsych/plugin-image-button-response@2.0.0.zip
Files
(11.8 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:ceb8ba46d8d0c2ba7937259f041b0beb
|
11.8 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/jspsych/jsPsych/tree/@jspsych/plugin-image-button-response@2.0.0 (URL)