Defining a global function (to use with on_load) #2587
-
Hey, I want to call a function with on_load for several trials like this
If I write the function after on_load intead of calling it, everything works. However, as I want to reuse the function without having to duplicate it everytime I thought I could just define it globally and then use it in trial, trial2, etc., but this way I get an error that the object is null. How is it possible to define the function outside of the trial? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @jan-tu-dresden, I think the problem is that the on_load: function() {
do_stuff("select");
} Does that work for you? |
Beta Was this translation helpful? Give feedback.
-
@jodeleeuw works perfectly, thank you very much. |
Beta Was this translation helpful? Give feedback.
Hi @jan-tu-dresden, I think the problem is that the
on_load
parameter is itself a function that doesn't take any arguments. So if you want to use a function that does take arguments, I think you'll need to wrap it in an anonymous function like this:Does that work for you?