12740

Shiny.onInputChange is not a function

I have code like is in my shiny app:

$(function() { Shiny.onInputChange('initialHash', parseHashQuery()); }); function parseHashQuery() { var result = {}; location.hash.replace(/^#/, '').split('&').filter(Boolean).forEach(function(part) { var pair = part.split('='); result[pair[0]] = pair[1]; }); return result; }

but I've got error:

common.js:59 Uncaught TypeError: Shiny.onInputChange is not a function at HTMLDocument.<anonymous> (common.js:59) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Function.ready (jquery.min.js:2) at HTMLDocument.K (jquery.min.js:2)

Answer1:

The solution was to use shiny event:

$(document).on('shiny:sessioninitialized', function(event) { Shiny.onInputChange('initialHash', parseHashQuery()); });

which was executed when Shiny.onInputChange was already defined.

Looking at the source code, Shiny is initialized in jQuery ready function but with timeout:

$(function() { // Init Shiny a little later than document ready, so user code can // run first (i.e. to register bindings) setTimeout(initShiny, 1); });

Recommend

  • How to have loop move to the next id available rather than doing the same continuously?
  • NullReferenceException with HtmlDocument reference in C#
  • Fixing the size of JEditorPane Content
  • HtmlAgilityPack and large HTML Documents
  • Convert base64 image to a file in Node Js
  • RethinkDB: “TypeError: 'Var' object is not callable” when using lambda function in filter
  • KoGrid JSON Dynamic widgets, with nested server calls
  • Cleave.js Phone CA
  • jQuery file download plugin
  • Deploying pre-encrypted configuration files to a production environment
  • Can one add a complex type item to ListModel?
  • Each Radiobutton for each form or 1 Form for all radiobuttons?
  • Understanding Intl.DateTimeFormat as a JavaScript object
  • What does a hyphen at end of a term mean
  • JSON Error when parsing “… has no method 'replace'”
  • Use sed with regex and (
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • XSLT foreach repeating nodes to flat
  • List images(01.png) and descriptions(01.txt) from directory
  • How can I extract results of aggregate queries in slick?
  • OOP Javascript - Is “get property” method necessary?
  • D3 nodes and links from JSON with nested arrays of children
  • Spring security and special characters
  • What is Eclipse's Declaration View used for?
  • PHP - How to update data to MySQL when click a radio button
  • Jquery - Jquery Wysiwyg return html as a string
  • Rearranging Cells in UITableView Bug & Saving Changes
  • SVN: Merging two branches together
  • Circular dependency while pushing http interceptor
  • retrieve vertices with no linked edge in arangodb
  • Linker errors when using intrinsic function via function pointer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • Bitwise OR returns boolean when one of operands is nil
  • Append folder name and increment by 1 using batch script
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • How to push additional view controllers onto NavigationController but keep the TabBar?