jquery

Hi where should we put jquery file and how we import into our site

If you want to explicitly include jquery in your page, you can call the following:

Yii::app()->clientScript->registerCoreScript('jquery');

Quote

Hi where should we put jquery file

Also, notice that the jquery script is already bundled with Yii.

what about the plugins?

Quote

what about the plugins?

Some are included, some others are extensions, and you could write your own wrapper extension for the plug-in you're interested in.

I did not quite get it. If I need to use a JQuery plugin, for example Datepicker, which is actually a folder consisting of many .js and .css files. Where should I put it best in the files tree of the application? And how should I publish it? Thanks.

Quote

I did not quite get it. If I need to use a JQuery plugin, for example Datepicker, which is actually a folder consisting of many .js and .css files. Where should I put it best in the files tree of the application? And how should I publish it? Thanks.

Well, for a datepicker, you can use this extension. Now, if you want to use another datepicker, I recommend you to write a Yii widget as a wrapper for it, so you don’t have to work with javascript code directly in your view (you can take the extension as an example). But, if you still want to work with javascript code directly, you’ll need to place the files you mention inside a directory and then publish that directory as an asset.

Thanks, man!

I noticed that using registerCoreScript jQuery loads towards the bottom of the <head>. How can I make sure it loads first?