So I am able to load a boat load of other scripts outside of this particular widget that i'm working on in a yii project. and even in the widget i am able to get an external script to register and load. However when i attempt to register a script that is in my widget's assets folder it registers just fine (as seen in a var_dump(Yii::app()->clientScript)
call) but it never loads in the browser. I have restarted my browser and that didn't help, here is the output of var_dump(Yii::app()->clientScript)
:
object(CClientScript)[10]
public 'enableJavaScript' => boolean true
public 'scriptMap' =>
array (size=0)
empty
public 'packages' =>
array (size=0)
empty
public 'corePackages' => null
public 'scripts' =>
array (size=1)
0 =>
array (size=2)
'jwplayer-licence-key' => string 'jwplayer.key = "8xU8+r4etXrBAwrr4Rzyq8niCsNZYC01/6XuUw==";' (length=58)
'jFileUploaderVars' => string 'var collegeId = 135717; var criteriaId = 0; var cameraMarkup = "<camera id="kdgtestcam" data-uuid="f89aee90-f319-0130-b0ac-12313940240c" data-videobitrate="131072" />";' (length=168)
protected 'cssFiles' =>
array (size=2)
'/ednet/css/bootstrap.min.css' => string '' (length=0)
'/ednet/css/font-awesome/css/font-awesome.min.css' => string '' (length=0)
protected 'scriptFiles' =>
array (size=2)
0 =>
array (size=4)
'/ednet/js/jquery-2.0.3.min.js' => string '/ednet/js/jquery-2.0.3.min.js' (length=29)
'/ednet/js/jwplayer/jwplayer.js' => string '/ednet/js/jwplayer/jwplayer.js' (length=30)
'/ednet/assets/6adc18e6/jfileuploader.js' => string '/ednet/assets/6adc18e6/jfileuploader.js' (length=39)
'//cameratag.com/1.8/cameratag.js' => string '//cameratag.com/1.8/cameratag.js' (length=32)
2 =>
array (size=2)
'/ednet/js/bootstrap.min.js' => string '/ednet/js/bootstrap.min.js' (length=26)
'/ednet/js/profileDisplay.js' => string '/ednet/js/profileDisplay.js' (length=27)
protected 'metaTags' =>
array (size=0)
empty
protected 'linkTags' =>
array (size=0)
empty
protected 'css' =>
array (size=0)
empty
protected 'hasScripts' => boolean true
protected 'coreScripts' =>
array (size=0)
empty
public 'coreScriptPosition' => int 0
public 'defaultScriptFilePosition' => int 0
public 'defaultScriptPosition' => int 4
private '_baseUrl' => null
public 'behaviors' =>
array (size=0)
empty
private '_initialized' (CApplicationComponent) => boolean true
private '_e' (CComponent) => null
private '_m' (CComponent) => null
and here is my code:
WIDGET:
class JFileUploader extends CWidget {
public $fileTypes;
public $controller;
public $model;
public $criteria;
public function run() {
$this->registerClientScripts();
echo $this->render('_jfileuploader', array('model' => $this->model, 'criteria' => $this->criteria, 'controller' => $this->controller, 'fileTypes' => $this->fileTypes), true);
}
public function registerClientScripts() {
$assets = dirname(__FILE__) . '/assets';
$baseUrl = Yii::app()->assetManager->publish($assets);
$cs = Yii::app()->getClientScript();
$cs->registerScript('jFileUploaderVars', 'var collegeId = ' . $this->criteria['college_id'] . '; var criteriaId = ' . $this->criteria['criteria_id'] . '; var cameraMarkup = "' . CHtml::tag('camera', array('id' => Yii::app()->params['cameraTag-camera'], 'data-uuid' => Yii::app()->params['cameraTag-uuid'], 'data-videobitrate' => 131072)) . '";', CClientScript::POS_HEAD);
$cs->registerScriptFile($baseUrl . '/jfileuploader.js', CClientScript::POS_HEAD);
$cs->registerScriptFile('//cameratag.com/1.8/cameratag.js', CClientScript::POS_HEAD);
}
}
the widget displays just as it should the only thing that i can't get to work is the jfileuploader.js
file and the jFileUploaderVars
script to load in the browser. Note:
the external script that will load is the last line in the registerClientScripts()
method. the two above it will not. any help would be greatly appreciated!