Is there a way to use 2 liveSend() functions on a page?

227 views
Skip to first unread message

MainlyMe

unread,
Dec 10, 2020, 7:28:08 AM12/10/20
to oTree help & discussion
Hi, 

I run in errors, when I want to use two liveSend() functions on a page, likely because there is no way to specify, which liveSend() I am calling on my html page. However, I need to send two unrelated values.

Is that a bug or meant to be that way? 
Calling it once with one function works perfectly fine. 


Thanks for the help!

Chris @ oTree

unread,
Dec 10, 2020, 11:50:35 AM12/10/20
to oTree help & discussion
you don't need 2 live methods. you can send your data as a dict with a key that indicates which type of message it is, and have your live method check that key to decide how to handle it.

MainlyMe

unread,
Dec 10, 2020, 12:32:21 PM12/10/20
to oTree help & discussion
Sounds good, will try that!
It's not always easy for non-programmers to transfer the examples given in the docs to somewhat more complex applications even though this might be obvious for people that do programming every day. But since otree targets people with various backgrounds,  I think an example with more than one value might help others too. :) 

Thank you!  

Chris @ oTree

unread,
Dec 15, 2020, 10:06:12 AM12/15/20
to oTree help & discussion
Thank you for the feedback :) there is an example here: https://otree.readthedocs.io/en/latest/live.html#data
Does that help?

MainlyMe

unread,
Dec 15, 2020, 10:52:08 AM12/15/20
to oTree help & discussion
Hi Chris,

I got it working with your comment from before, but I am sure this helps other people that might run in the same issues. 

Thank you! :) 

Ana Cecilia Quiroga

unread,
Mar 18, 2021, 6:13:57 AM3/18/21
to oTree help & discussion
Hi! I'm trying to integrate live pages in my experiment. 
I am trying to understand exactly how the live methods work to implement them correctly, is the tic-tac-toe game code available somewhere?
Thank you!

Ana Cecilia Quiroga

unread,
Mar 18, 2021, 6:26:03 AM3/18/21
to oTree help & discussion
Hi Chris... another question:

If I am not using groups, is it necessary to use the id_in_group inside the dictionary when sending data to the page?

Chris @ oTree

unread,
Mar 18, 2021, 6:26:25 AM3/18/21
to oTree help & discussion
There are a bunch of examples here: https://otree-more-demos.herokuapp.com/demo

Ana Cecilia Quiroga

unread,
Mar 18, 2021, 7:36:25 AM3/18/21
to oTree help & discussion
Thank you!
Reply all
Reply to author
Forward
0 new messages