Hi!
I creating a website, entire in ajax. On some pages I have a widget that uses javascript ( the rating system ). The problem is I fetch from the server not the whole page, but only the content changing from page to page. And the scripts and styles I register in Widget classes do not appending to the page, because I don’t fetch the <head> tag from the server.
<?php
class VStar extends CWidget
{
public $assets = '';
public $options;
public $jsoptions;
public $id = 'vstar';
public function init()
{
$this->assets = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.vstar.assets'), false);
$this->id = $this->id . '_' . uniqid();
$this->jsoptions = ( empty($this->options) ? '' : CJavaScript::encode($this->options) );
Yii::app()->clientScript
// Already rendered
->registerCoreScript('jquery')
// Will not be rendered
->registerCssFile($this->assets . '/css/index.css')
// Will not be rendered
->registerScriptFile($this->assets . '/js/vstars.js');
parent::init();
}
Do you have any ideas? Should I include all the widgets on the first run of the application?