I've been struggling for hours to make this work, but I can't seem to find a solution. I'm working with Ruby, Haml, Sinatra, and Highcharts. I've created a Ruby HighCharts object that includes a Haml partial with the :javascript filter followed by the necessary HighChart JS.
Everything works perfectly when I test it on the main route ("/"). The JQuery, Highcharts, and inline JS from the partial load without any issues and the chart is displayed correctly.
However, when I move the EXACT same code to another route (e.g. "/user/:id") and respective view, the chart doesn't render. In Firebug, I can see that Jquery, Highcharts, and JS from the partial are loading correctly and the Ruby variables are interpolated exactly as they should be. So, the JS sent to the browser is the same, but the chart only renders on the main route.
One thing that might help diagnose the issue: on the "user/:id" page, when I inspect the external Jquery and Highchart scripts using Firebug in Chrome, it shows "Access to restricted URI denied." However, on the main page ("/"), it displays the full javascript text. When I check the Ruby interpolated inline Highcharts JS on both pages, it shows the complete text.
Could it be that the Jquery and Highcharts external scripts are not loading correctly on the "user/:id" page? Any thoughts on what the problem might be?
Here's my layout haml file, in case it helps in diagnosing the issue:
!!!
%html
%head
%title= @title
%link(rel="stylesheet" href="/style.sass")
%script{:src => "javascripts/jquery-1.6.2.js"}
%script{:src => "javascripts/js/highcharts.js"}
%body
#framecontent
.innertube
#nav
%ul
%li
%a(href="/") Home
%li
%a(href="senate") Users
#maincontent
.innertube
- if flash[:notice]
%p.notice
= flash[:notice]
- if flash[:error]
%p.error
= flash[:error]
=yield