This extension sets up require js for use in your Yii project. Once installed you use a widget in a view or layout to setup require and then you can use require js as you normally would starting at an entry script (usually main.js) where you can load further modules and dependencies etc.
Usage ¶
How to Use:
- Place the yii-require-js folder in your extensions directory
- Use the widget in any view that you want to use require js
- Create main.js in /protected/components/js/ and start coding js
eg:
$this->widget('ext.yii-require-js.YiiRequireJsWidget');
Config:
If you would prefer a different js starting point instead of main.js define this in your main.php file like so:
eg:
'params' => array(
'yii-require-js'=>array(
'initialModule' => 'myModule'
),
If you would prefer to load your scripts from another directory other than /protected/components/js you can define this in your main.php config like so:
eg:
'params' => array(
'yii-require-js'=>array(
'scriptsDirectory' => 'application.components.js.requireModules'
), ...
Resources ¶
This project makes use of RequireJS. Located here: http://requirejs.org/
Component
Hi, thank you for this extensions, I do not play with it yet, but just a question did you think to build it? as a component maybe better?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.