ochrons / scalajs-spa-tutorial

Tutorial for creating a simple Single Page Application in ScalaJS
Apache License 2.0
672 stars 230 forks source link

Using jQuery plugin libraries #30

Closed chrissherwin closed 8 years ago

chrissherwin commented 8 years ago

Hi, I'm new to scala, scalajs and react, although I'm an experienced dev. I have followed this great tutorial and am now trying to adapt/extend it. Specifically I am trying to display data using a 3rd party plugin (pivottable) which uses standard jQuery syntax:

$("#somediv").pivotUI([{color: "blue", shape: "circle"},{etc}], options)

I have created traits/implicits as per [http://www.scala-js.org/doc/interoperability], however, when the page renders the pivot is empty. But if I view the page a second time (by clicking withi the app - not a full refresh) the data appears. So the async data call must be succeeding but when it completes it is not updating the component that draws the pivot table. (If I render the data in an html table it works fine.)

I am rendering the target div in Backend.render and then executing the js from componentDidMount. I am not sure this is the right way. Is there a 'right' way to invoke jQuery plugins?

Many thanks.

ochrons commented 8 years ago

Please resubmit your question to Stack Overflow (with scalajs tag), which is much better suited for these kind of generic Scala.js questions. Thanks!