Add jQuery Mobile

Yii already integrates jQuery and jQuery UI, it would be nice to complete the family with the integration of jQuery Mobile (Beta 3 now but probably final when Yii 2.0 will be ready).

I don’t like the integration of client side libraries as such. It should be abstracted away in CClientScript and similar. One of the reasons I choose PHP (with Yii) over .NET is that I feel I have more control.

I work at where we focus on mobile websites. We use Yii and jQuery mobile in all of our projects and they seem to fit perfectly together. For example: I have extended the CController into a MobileController, which all other controllers extend. The MobileController ensures that the layout is only sent along with the first load. Since jQuery loads all following pages with ajax, it doesn’t need the layout, and thereby saving both server and client side load time.

My conclusion: Yii 2.0 should be less attached to jQuery and focus on features like minifying and combining css and JS but could provide ClientScript and Html classes to support the jQuery framework.

If you like the idea of more PHP programming and less HTML, you could extend CHtml to a MobileHtml which makes use of jQuery mobile features. In fact I use that approach on links because it simplifies the views a bit.

You should suggest this elsewhere since I’m starting from the fact that jQuery and jQuery UI are already part of the framework.

Moreover, I think that having a jQuery Mobile ready framework would be nice, without having to workaround rough edges by myself.

You’re probably right.

What do you mean by “ready”? My experience is that there isn’t really any workarounds needed. jQuery mobile works very well with Yii. Do you have any examples?


I think that it should be ready-to-use. Mobile-optimized websites are a milestone in web development.

It really has little to do with Yii…

The controller I’ve made is less than four lines, and is not even required by jQuery Mobile, it’s just an enhancement.

It is. No workarounds required. That’s the whole idea about jQuery Mobile; it’s based on HTML markup, to make it as easy as possible. All you have to do is load the JS file.

Sure they are, my company sells nothing else than mobile websites.

Leaving aside the implementation matter, the original question was about adding jQuery Mobile to Yii, as jQuery and jQuery UI are already there and it would nicely complete the family. The argument that you can add it by yourself is just as valid as for jQuery and jQuery UI which are already there.

I agree with ekerazha, jQueryMobile simply should be a core script.

No, definitely not.

I’d rather see support for HTML5 Boilerplate, with accessible media queries.

The rest would then be a piece of cake.

Without jQuery Mobile…

To see what you can do - entirely without jQuery Mobile - check this:


jQuery Mobile is great, like jQuery UI - but no serious web designer (IMHO) would use it…

I’d rather see Yii switch from using BluePrint to Skeleton:

I am using it for my website:

Resize the browser window to see it adapt.

I haven’t really finished making it responsive, but you get the idea.

Here’s how it looks on iPhone:


And on iPad: (portrait) (landscape)

So, I’d rather see Yii using Skeleton by default.

Not even the author of BluePrint uses BluePrint these days…

I agree, we should made a poll for this!

This has nothing to do with the original question. I’m saying that jQuery Mobile would nicely complete the family, as Yii already integrates jQuery and jQuery UI. I’m a serious designer and I don’t have any problem with UI and Mobile.

Swithing from BluePrint to Skeleton for the default theme is another story.

Most probably we’ll have multiple bootstrap application types (yiic webapp) and maybe an ability to create your own ones.

there is no use to include jQuery Mobile to Yii code in my opinion.

if including it, i think yii is not a common framework, but a heavy framework.

There is nothing of “heavy”, if you don’t want it, just don’t use it. There isn’t any reason to include jQuery UI and not jQuery Mobile.

I would rather see jQuery UI go.

As for jQuery mobile… There are other more capable solutions out there.

Such as Zepto.js.

Zepto is not based on jQuery while Yii is based on jQuery (jQuery and jQuery UI are bundled, jQuery is used for active controls etc.), just like jQuery Mobile is jQuery-based, obviously.

I just found this, haven’t noticed it yet:

Doesn’t this do the job?

You sound like a broken record, dude.

I do not use jQuery UI at all when I use Yii, and I prefer it that way.

Zepto is 4K, and does pretty much what jQuery does.

It’s highly recommended. ;)

Why lock Yii users in, when you don’t have to?

I agree with Thomas Jensen: Yii 2.0 should concentrate on asset management, like minification, uinification, etc. - IMO it really needs to be improved.

Curious: what makes it so hard to just use jQuery Mobile??

Right now?

I don’t get it. :)