Pass a PHP string (which represents a JS function) through json_encode()

parfumeril

New Member
I'm using this PHP/CodeIgniter library for jQuery Highcharts: http://www.crustiz.com/php-jquery/highcharts-library-for-codeigniter/The way that library does things is that it builds a PHP array of options, then converts it to json using json_encode (see line 273 of that library) which is then used by the jQuery Highcharts plugin. This is fine, except the option I'm trying to use is the tooltip formatter, which needs to be a javascript function, not a string (see http://www.highcharts.com/ref/#tooltip).Since the library doesn't have a tooltip function, I created one as a test:\[code\] function set_tooltip() { $this->a_options['tooltip']['formatter'] = 'function() { return this.series.name + "<br>" + this.x + ": " + this.y }'; return $this; }\[/code\]But this doesn't work as the JS function is output as a string, not a function. Anyone know if there is a way to have it be a function after passing through json_encode without rewriting that part of the library?
 
Back
Top