jQuery with Yii


What are the benefits of using the "built in" jQuery in Yii vs. importing jQuery as usual and using it that way?

The reason for my question is that I’d like to outsource the development of the layout files to an external agency. However, I’m a bit skeptical to ask them to follow the syntax of the Yii framework for jQuery rather than just using the common way. I could of course convert it myself after I’ve received the files, but what if changes are required later on.

I’m a bit puzzled by this and would really appreciate some advice on your experience with this.

According to this article:

With Yii it is a little easier to include JS functionality because Yii encapsulates some nice jquery ui plugins. Have a look at zii.widgets.jui. Yii does make it easier to insert jquery functionality.

I personally don’t like writing javascript inside a php string, and I’m comfortable writing my own jquery outside of Yii. Plus I like to keep my JS separate from my php. I do make use of Yii’s registerScriptFile to handle inserting my JS files.

For the most part I think it comes down to personal preference. I would rather have my own JS files which I could reuse and drop onto other non-yii websites.

Hi guys,

I’m using the “registerScript” in some places of my code, and it works fine with views that are rendered by a ‘render’ method inside controller actions. I also have a partial view, and it contains a <script></script> block with some jQuery. Everything is ok until I use a registerScript instead! It does not generate any scripts for me, and I still don’t know why. Had to get back the <script></script> block. I’ve checked the code - it should be fine. I’ve tried to insert some dummy javascript in a registerScript, but no positive results so far.

What am I doing wrong?