如何在Yii中使用NLSClientScript扩展?(How can I use the NLSClientScript extension in Yii?)
如何使用扩展程序http://www.yiiframework.com/extension/nlsclientscript/ ?
我试过这个:
配置/ main.php:
'clientScript' => array( 'class' => 'ext.NLSClientScript',景色/布局/ main.php:
$cs = Yii::app()->getClientScript(); $systemJsPath = Yii::app()->getAssetManager()->publish( Yii::getPathOfAlias('system.web.js' ), false, -1, false ); $cs->registerScriptFile('jquery'); $cs->registerScriptFile( $systemJsPath . '/custom.js'); $cs->registerScriptFile( $systemJsPath . '/ext/plugins/jquery.form.js');但它不起作用。 jQuery没有加载。
How can I use the extension http://www.yiiframework.com/extension/nlsclientscript/ ?
I tried this:
config/main.php:
'clientScript' => array( 'class' => 'ext.NLSClientScript',views/layouts/main.php:
$cs = Yii::app()->getClientScript(); $systemJsPath = Yii::app()->getAssetManager()->publish( Yii::getPathOfAlias('system.web.js' ), false, -1, false ); $cs->registerScriptFile('jquery'); $cs->registerScriptFile( $systemJsPath . '/custom.js'); $cs->registerScriptFile( $systemJsPath . '/ext/plugins/jquery.form.js');But it doesn't work. jQuery is not loaded.
最满意答案
Jquery在Yii中被称为核心脚本,应该使用CClientScript::registerCoreScript 。
在你的例子中:
$cs->registerCoreScript('jquery');所有核心脚本的短名称都列在YII_PATH/web/js/packages.php 。
Jquery is known as a core script in Yii and should be registered using CClientScript::registerCoreScript.
In your example:
$cs->registerCoreScript('jquery');The short names for all core scripts are listed in YII_PATH/web/js/packages.php.
更多推荐
发布评论