On liveSend and button

173 views
Skip to first unread message

Shiyu ZHANG

unread,
May 10, 2022, 2:29:45 AM5/10/22
to oTree help & discussion
Hi all,

  I know that if we put a button tag <button onclick="my_liveSend"></button>, the defined liveSend function would be called once the button is clicked. Meanwhile, the form would be submitted, meaning that a player would then move to the next page.

  The other approach is to create a button that does not submit the form, i.e. <button type="button" onclick="my_liveSend"></button>, but call form.submit() inside liveRecv().

  I am wondering which one is better. Shall I worry that the live message might be lost if one leaves the page too quick?

Best,
Jake

Chris @ oTree

unread,
May 10, 2022, 2:34:30 AM5/10/22
to Shiyu ZHANG, oTree help & discussion
Yes the message might not get sent if you navigate to the next page right away. So you should send the message, then in your live_method send a confirmation back to the page. When your liveRecv received the confirmation, you can submit the page. 

Sent from my phone

On May 10, 2022, at 2:29 PM, Shiyu ZHANG <zsh...@gmail.com> wrote:

Hi all,
--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/536155ed-e270-4924-a435-8be4c5df8bf0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages