Sending messages to parent div from Shiny server

Hi everyone,
we would like to use Shiny Apps in quizzes at our universities learning management system (Moodle). Therefore, we have to embed the Shiny App in our quiz questions (e.g. as iframe). Locally we managed this by listening on a shiny:inputchanged event and then use postMessage command to send a message to the parent window.

But on our Shiny Server (and shinyapp.io) all messages get discarded from buffer. Can we change this behaviour and allow messages that go out to our Moodle instance?

Kind regards
Simon

This article might be helpful - please see shiny:inputchanged.

1 Like

Thanks for your hint. Locally I can run my app and have it communicate with a parent div now. But when I deploy the app on shinyapp.io the messages get discarded from the buffer. :open_mouth:

Is there a setting I can change so that the messages are not discarded but send to the parent div also when the app is hosted on shinyapp_io?

Here is a link to my minimal demo app on shinyapp_io:
https://f1-htw-berlin.shinyapps.io/shinymoodlequiz_v2

The custom JS code used is:

$(document).ready(function() {
  
  $(document).on('shiny:inputchanged', function(event) {
    // console.log("Something changed. Value now is "+event.value);
    // console.log("Change happened at "+event.name);
    var wertepaar = [event.name, event.value]
    parent.postMessage(wertepaar, "*");
  });

});

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.