I have a CakePHP site and wish to render jqplots on the fly. At the moment I am unable to render anything at all…
In my default layout I have:
// ../layouts/default.ctp
echo $this->Html->script('jquery');
echo $this->Html->script('jquery.jqplot.min');
echo $this->Html->css('jquery.jqplot.min');
When I view the source, all these files are available to the browser (i.e. I can click on each of the src links and it pulls the file just fine).
In my View file:
// ..Views/Plots/index.ctp
<div id="mychart" style="height:400px;width:500px; "></div>
<script>
$(document).ready(function(){
$.jqplot('mychart', [[3,7,9,1,4,6,8,2,5]]);
});
</script>
When I view the source, everything is displayed in the correct place i.e. scripts in the <head> section, and the view sits nicely inside my #content div. What the hell am I doing wrong?! Been tearing my hair out for the past three hours!
FIXED
Problem appeared to be with the version of jquery I was using. I am now using the version of jquery that was included with jqplot (v1.6.4).