Help with integrating jQuery plugin to shiny app

296 views
Skip to first unread message

Josh Lindsteadt

unread,
Oct 12, 2014, 8:20:39 PM10/12/14
to shiny-...@googlegroups.com
I am trying to integrate the autoNumeric jQuery plugin (http://www.decorplanit.com/plugin/)  into my shiny app to add currency and comma separators into a text input.  I am a totally new a jQuery, and would appreciate any help.  Below is a copy of my code where  HTML('<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"> </script>')  & HTML('<script src="autoNumeric-(with latest version).js",type=text/javascript> </script>'), are links to the plugin, and money.js is a script I have stored in the www folder in the app directory.  Thanks! 

ui.R

library(shiny)

shinyUI(
  

  fluidPage(    
    
    sidebarLayout(      
      
      sidebarPanel(
        HTML('<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"> </script>'),
        HTML('<script src="autoNumeric-(with latest version).js" type=text/javascript> </script>'),
        HTML('<script src="money.js" type="text/javascript"></script>'),
        
        HTML('<div id="currency">'),
            numericInput('dollarValue', "Input Dollar Value", "1000"),
        HTML('</div>')
      ),
      
      
      mainPanel(
        verbatimTextOutput('dollar')
      )
      
    )
  )
)


Server.R

library(shiny)

shinyServer(function(input, output) {
    
    output$dollar <- renderPrint({
        dollar <- input$dollarValue
        dollar
    })

})


money.js

jQuery(function($) {
  $('#currency').autoNumeric('init');    
});

Huidong TIAN

unread,
Oct 13, 2014, 4:36:42 AM10/13/14
to shiny-...@googlegroups.com
Download the js package to your local directory, and try the following code: 


shinyUI(bootstrapPage(
  # Add custom CSS & Javascript;
  tagList(
    tags$head(
      tags$script(type="text/javascript", src = "jquery-latest.min.js")
    )
  ),

Josh Lindsteadt

unread,
Oct 13, 2014, 7:34:03 PM10/13/14
to shiny-...@googlegroups.com
I'm still not having any luck.
Reply all
Reply to author
Forward
0 new messages