57632

Shiny semantic Ui elements in renderUI

This question is based on my previous about adding ui semantic elements in shiny apps. Here the links, to recent questions:

Rating Stars in R shiny app, How to flip up shapes in shiny by clicking a button?

I am able to display rating stars and shapes if they are constructed directly in UI.R. However, I need them within a renderUi, since I have a login page and use observe for the UI.

Here example code:

Ui.R:

shinyUI(semanticPage( shinyjs::useShinyjs() ,uiOutput("test")))

Server.R:

library(shiny) library(shinyjs) library(shiny.semantic) library(highlighter) jsCode <- " $('.shape').shape(); $('.ui.rating') .rating({}); " shinyServer(function(input, output) { runjs(jsCode) output$test <- renderUI({ tagList( div(class="ui shape", div(class="sides", div(class="ui header side active","This side starts visible."), div(class="ui header side","This is yet another side"), div(class="ui header side","This is the last side"), div(class="ui header side",div(class="ui star rating")) ) ), tags$button(id="test", class="ui button", "Flip", onclick="$('.shape').shape('flip up');") ) }) })

Problem is, that rating stars are not displayed in the app, if I put them inside a render UI. How can I fix this?

Answer1:

You can do:

output$test <- renderUI({ tagList( div(class="ui shape", div(class="sides", div(class="ui header side active","This side starts visible."), div(class="ui header side","This is yet another side"), div(class="ui header side","This is the last side"), div(class="ui header side",div(class="ui star rating")) ) ), tags$button(id="test", class="ui button", "Flip", onclick="$('.shape').shape('flip up');"), tags$script(HTML("$('.ui.rating').rating({});")) ) })

Recommend

  • How to access dataframe from another observeEvent?
  • How to Focus on textinput field in alert combined with modaldialog in R?
  • different number of column name in selectIput Shiny
  • How to listen for multiple events which contain an isolate() in a shiny eventReactive handler
  • R Shiny: Isolate dynamic output within dynamic tabs
  • Labeling Gmail message (not the whole thread) with Google Apps Script
  • Exclude null properties in JMS Serializer
  • DataFrame transformation in Spark, Java
  • How do I keep the legends/colours of SSRS charts consistent?
  • What is the Performance, Safety, and Alignment of a Data member hidden in an embedded char array in
  • Is it good practice to put Edge Side Includes into my templates?
  • How can i get window.location.pathname on my test file using Jest?
  • Calling a second level base class constructor
  • Gson serializing Spring beans
  • Approximate Order-Preserving Huffman Code
  • Jquery popup on mouse over of calendar control
  • Firefox Extension - Monitor refresh and change of tab
  • ADO and msqli connections very slow
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • Django rest serializer Breaks when data exists
  • Highlight one bar in a series in highcharts?
  • Recording logins for password protected directories
  • DomPDF {PAGE_NUM} not on first page
  • Change JButton Shape while respecting Look And Feel
  • Is there any way to access browser form field suggestions from JavaScript?
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • javascript inside java/jsp code
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • To display the title for the current loaction in map in iphone
  • jquery mobile loadPage not working
  • jQuery tmpl and DataLink beta
  • Web-crawler for facebook in python
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Traverse Array and Display in markup
  • A cron job substitute?
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Getting error when using KSoap library to consume .NET web services
  • How to set the response of a form post action to a iframe source?
  • Unable to use reactive element in my shiny app