2013-10-01 49 views
0

因此,我可以在yii項目中處理的特定小部件之外加載其他腳本的小船加載。甚至在小部件中我都能夠獲得一個外部腳本來註冊和加載。然而,當我嘗試註冊一個腳本,它位於我的小部件的資產文件夾中時,它註冊得很好(如在var_dump(Yii::app()->clientScript)調用中所見),但它永遠不會在瀏覽器中加載。我已經重新啓動我的瀏覽器,並沒有幫助,這裏是var_dump(Yii::app()->clientScript)輸出:Yii腳本文件註冊但從未在瀏覽器中加載

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 

這裏是我的代碼: 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); 
    } 
    } 

小組件顯示的只是因爲它應該是唯一我無法工作的是在瀏覽器中加載的jfileuploader.js文件和jFileUploaderVars腳本。 Note:將加載的外部腳本是registerClientScripts()方法中的最後一行。上面的兩個不會。任何幫助將不勝感激!

+0

是否動態資產文件夾獲取正確創建?例如,是否存在'/ ednet/assets/6adc18e6/jfileuploader.js'?如果沒有,刪除6adc18e6目錄應該強制Yii重新填充它。 。 。 – ernie

+0

是的,它正在創建。我忘了提及我刪除了資產文件夾中的所有內容,所以Yii會重新生成它。但它沒有改變任何東西。該文件夾被重新創建,js文件被放入它,但從未在瀏覽器中加載過 – Joe

+0

什麼是生成的HTML顯示?是否有適當的