Charts rendered only when browser refreshes when using page caching
lamoglia opened this issue · comments
I noticed that when I'm using page caching (gem 'actionpack-page_caching'), the charts are rendered only when a full refresh is made (i.e. not when navigating to the chart page using internal links, only when pressing f5).
I think it may be something related to encapsulate_js method in layout_helper.rb : it checks for the referrer (request_is_referrer) to conditionally renders a block of js, and when the page is fully cached, it doesn't have the chance to render it differently on the second call (when not refreshing).
Anyone already experienced this? Any thoughts on using page caching with lazy_highcharts?
I've managed to instantiate the charts using jquery $(document).ready
. It allows this gem to work with rails page caching.
It seems that some work was made for not relying on jquery to include the charts, but it leaves this functionality gap for cached pages.
@lamoglia could you please explain exactly how you implemented this?
I'm having the same issue but I fail to understand how to instantiate the chart using jquery.
Thank you in advance.
I've forked this repo and changed how the chart is inserted and the specs (see commit https://github.com/lamoglia/lazy_high_charts/commit/011af5f7574b678c4fb5d35c5b579c90bbc663c2).
Then, in my app I'm using this forked version. You can test if it works for you changing the lazy_high_charts dependency in your gemfile:
gem 'lazy_high_charts', :git => 'git://github.com/lamoglia/lazy_high_charts.git'
cool, if the tips is good, please pr.
Sure. Did it work for you @Goncalo-Almeida ?
Sorry for the delayed response.
First, thank you for your answer.
I haven't tested it yet. I'm only able to test this next Monday.
I'll report back first thing in the morning.
Hi! Thanks for this @lamoglia :)
Worked like a charm 👍