How to use jquery in yii?
As you said above, you can register a new script block or register a new external script file. You can also register assets in plugins that will process entire JS folders and merge them into your application.
Thus, there are many ways to use jQuery in Yii.
How to use my jquery in yii
JQuery comes bundled and activated using jQuery, and the jQuery library itself is considered the core of the script, so there is no need to embed your own jQuery.
You can overwrite inline jQuery with your own by setting:
$cs = Yii::app()->clientScript; $cs->scriptMap = array( 'jquery.js' => Yii::app()->request->baseUrl.'/js/jquery.js', 'jquery.yii.js' => Yii::app()->request->baseUrl.'/js/jquery.min.js', ); $cs->registerCoreScript('jquery'); $cs->registerCoreScript('jquery.ui');
Something like this is somewhere inside your layout, action or view. I prefer to put this in the layout and personally manage my own version of jQuery.
Why is this no different than using jQuery in any other way?
Mainly due to standardization and interoperability of the structure and its components. By pre-connecting with built-in hooks for the JQuery UI widget and JQuery elements, it is generally easy to build reusable and clean JS objects for use in your application.
Also, I like jQuery, so it makes sense that it appears in my way. However, this is not a call to arms, as JQuery is the only JS library / framework, and you should really think about what is best for you before you choose.