Renderpartial Via Ajax Affecting My Theme


To save initial page load I’m using ajax to populate a bootstrap accordion when it’s opened.


$this->renderPartial('_callhistory', array(



		), false, true);

But I’ve run into a couple of problems. This renders the view fine, but the “Abound” theme breaks, (styles change, JS stops).

Plus occasionally the rendered view needs to be refreshed. I call the same functions to do the job, but the widgets (select2 and CJuiDatePicker) dont work after the second ajax call.

Any help will be appreciated.

To be honest I’m not fussed about using select2 in this case, I just need to get datepicker to work reliably. So if there’s a way to include a datepicker without setting the $processOutput parameter of renderPartial, that would also solve my problem :)

You could just register the datepicker js as default, for example in the init method of CClientScript. The datepicker skript will be on every page even if the component is not used.

BaseClientScript extends CClientScript {

  public function init()


   $datePickerJs = Yii::app()->baseUrl.'/js/datepicker.js';

   $this->registerScriptFile($datePickerJs , CClientScript::POS_HEAD);



Generally i use a differnt approach for js files. I completly disabled the publishing of js files through yii. I use uglify to combine all the js files in my project into one file and that will be included in the layout.