I have a view that renders some data in a CListView
and a Highcharts graphic.
Please note that the pager of the CListView
works the following way: it requests the "new page" to the server, the servers renders the entire content of the page and sends it to the CListView
. The body is then replaced with the content that is being sent, with something like this: $('body').html(rendered_html_response)
.
I also have a dropDownList
that imitates this behavior. This is the code:
<?php
echo CHtml::dropDownList('usage', 'cg', array(
'd'=>'Daily',
'm'=>'Monhly'
), array(
'ajax'=>array(
'type'=>'POST',
'url'=>$this->createUrl('admin/user', array(
'id'=>$user->id)
),
'update'=>'body',
'data'=>array('cg'=>'js:$(this).val()'),
'options'=>array(
Yii::app()->session['cg']=>array(
'selected'=>true
)
)
)
));
?>
Anyways, there is a problem. When I use the CListView
, everything works fine (as in: the page's content is refreshed without the page being reloaded, the charts and the data are rendered correctly, etc...), but when I select something using the dropDownList
, the server renders the reply, sends it to the client, the client starts replacing the content of body
, but then I get this error: http://www.highcharts.com/errors/16
.
I tried disabling highcharts.src.js
this way:
public function beforeAction(){
if(Yii::app()->request->isAjaxRequest){
Yii::app()->clientScript->scriptMap['highcharts.src.js'] = false;
}
return true;
}
but then I get the typical undefined
javascript error (means that something is trying to use Highcharts
, which is not defined).
Where is the problem and how can I fix it?