Skip to content

Commit

Permalink
Merge pull request michelson#43 from kylewelsby/master
Browse files Browse the repository at this point in the history
fails when jQuery is precompiled
  • Loading branch information
michelson committed Jan 15, 2012
2 parents b82fd46 + b68d8e3 commit e197986
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/lazy_high_charts/layout_helper.rb
@@ -1,13 +1,13 @@
# coding: utf-8
module LazyHighCharts
module LayoutHelper

def high_chart(placeholder, object , &block)
object.html_options.merge!({:id=>placeholder})
object.options[:chart][:renderTo] = placeholder
high_graph(placeholder,object , &block).concat(content_tag("div","", object.html_options))
end

def high_stock(placeholder, object , &block)
object.html_options.merge!({:id=>placeholder})
object.options[:chart][:renderTo] = placeholder
Expand All @@ -29,26 +29,26 @@ def build_html_output(type, placeholder, object, &block)
options_collection << "#{k}: #{object.options[key].to_json}"
end
options_collection << "series: #{object.data.to_json}"

graph =<<-EOJS
<script type="text/javascript">
jQuery(function() {
// 1. Define JSON options
var options = { #{options_collection.join(",")} };
// 2. Add callbacks (non-JSON compliant)
#{capture(&block) if block_given?}
// 3. Build the chart
var chart = new Highcharts.#{type}(options);
window.onload = function(){
jQuery(function() {
var options, chart;
options = { #{options_collection.join(",")} };
#{capture(&block) if block_given?}
chart = new Highcharts.#{type}(options);
});
</script>
};
</script>
EOJS

if defined?(raw)
return raw(graph)
else
return graph
end

end
end
end

0 comments on commit e197986

Please sign in to comment.