Rails partial not rendering with JavaScript -
i'm trying render partial in app, reason not render. think has asset pipeline , fact not correctly implementing javascript want use in partial. test partial simple sentence works fine. can direct me in proper use of javascript in app?
here jsfiddle of trying show: http://jsfiddle.net/yzqg4/
problematic partial:
<%= javascript_include_tag "highcharts", "exporting", "jquery-1.4.2.min", "rails" %> <script type="text/javascript" charset="utf-8"> $(function() { var chart; $(document).ready(function() { chart = new highcharts.chart({ chart: { renderto: 'panel_contents', type: 'column' }, xaxis: { categories: ['automotive', 'agency', 'contractor', 'country club', 'other'] }, yaxis: { min: 0, title: { text: 'business summary' }, stacklabels: { enabled: true, style: { fontweight: 'bold', color: (highcharts.theme && highcharts.theme.textcolor) || 'gray' } } }, legend: { align: 'right', x: 100, verticalalign: 'top', y: 0, floating: true, backgroundcolor: (highcharts.theme && highcharts.theme.legendbackgroundcolorsolid) || 'white', bordercolor: '#ccc', borderwidth: 1, shadow: false }, tooltip: { formatter: function() { return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' + 'total: ' + this.point.stacktotal; } }, plotoptions: { column: { stacking: 'normal', datalabels: { enabled: true, color: (highcharts.theme && highcharts.theme.datalabelscolor) || 'white' } } }, series: [{ name: 'mobile', data: [5, 3, 4, 27, 2]}, { name: 'foursquare', data: [2, 2, 3, 2, 1]}, { name: 'facebook', data: [3, 4, 4, 2, 5]}, { name: 'yelp', data: [3, 4, 4, 2, 5]}, { name: 'google', data: [3, 4, 4, 2, 5]}] }); }); }); </script>
working test partial:
<h1> hello world </h1>
thanks!
add before javascript code this:
<div id="panel_contents"></div>
p.s. besides it's better move javascript inclusion out of partial or using content_for
Comments
Post a Comment