开发者

jQuery mobile: degrade gracefully in non-supported browsers?

I'm developing a site in jQuery mobile (jQM). It's great, but one thing is troubling me.

jQM is not supported in all mobile browsers (notably BlackBerry 5). The site looks gorgeous in the Android browser: on Opera Mini on Android, it's actually broken :(

I've developed the site using progressive enhancement, naturally. So it works without jQM - if I can tell the browser not to use it!

Question: for platforms like Opera Mini on Android, is there a way I can check for jQM support, and totally unapply jQM as appropriate?

  • If jQM is supported in this browser, use it.
  • If it isn't, don't load the jQM javascript, don't load the jQM stylesheets, and use the basic JavaScript site.

I know about the gradeA() property, but you presumably have to load jQM to u开发者_如何学运维se it:

$.mobile.gradeA()

Thanks!


jQuery Mobile tests browser features itself.

You should customize the code to make it resign from doing its enhancements. Try here if you're interested: https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.support.js

Also: If it decides to work - it probably should. Try fixing the problems instead of trying to get jQuery Mobile to degrade

[edit]

Ok. let me explain. JQM, following to the idea of progressive enhancement, tests browser capabilities and kicks in with its widgets and stuff when the browser passes tests. This is why I say it should work if it tries.

If it tries to enhance and fails - it's a bug/missing support on the JQM side and in an ideal world you should expect it to be fixed. Reality suggests you can't expect it, but you can hope for it ;) It's not a release yet.

What I ment with "Try fixing..." is that you should download the JQM repository, add a line or two to the support tests and make them detect the feature that causes JQM to fail in that particular case. Then run make and you have a brand new JMQ working for you.

After that you can suggest your change to the core team and they'll improve on it.

[edit]

This is actually what you really wanted:

A nice way to get your support-sniffing code in.

You can implement your own gradeA function that would return $.support.mediaquery&&yourcondition

See: http://jquerymobile.com/demos/1.0a4.1/#docs/api/globalconfig.html

This can prevent JQM from working with browsers you don't want.


How about using jquery support object? There are new properties for mobile. From docs, gradeA is a shortcut for $.support.mediaquery.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜