用于移动和桌面的 jQuery Mobile?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5048695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:27:07  来源:igfitidea点击:

jQuery Mobile for mobile and desktop?

jqueryjquery-uimobilejquery-mobile

提问by ZolaKt

I'm developing a web app. MySql/PHP back-end, and HTML/jQuery front-end.

我正在开发一个网络应用程序。MySql/PHP 后端和 HTML/jQuery 前端。

I wanted to use jQuery UI framework.

我想使用 jQuery UI 框架。

Now is see that jQuery Mobile is out, and I want to make the app accessible to mobile devices as much as possible.

现在看到 jQuery Mobile 出来了,我想让移动设备尽可能多地访问该应用程序。

I Googled, but didn't find a quality answer.

我用谷歌搜索,但没有找到高质量的答案。

Can I make it all to work form the same code if I use jQuery Mobile?

如果我使用 jQuery Mobile,我可以使用相同的代码来完成所有工作吗?

I'd like it to show mobile widgets if accessed form mobile browser.
But use jQuery UI widgets is accessed from desktop browser.

如果从移动浏览器访问,我希望它显示移动小部件。
但是使用 jQuery UI 小部件是从桌面浏览器访问的。

Is that possible just by using jQuery Mobile and its markup, or I have to write the front-end for mobile (jQuery Mobile) and desktop (jQuery UI) separately?

是否仅通过使用 jQuery Mobile 及其标记就可能实现,或者我必须分别编写移动(jQuery Mobile)和桌面(jQuery UI)的前端?

That is, can jQuery Mobile, automatically "fall-back" to jQuery UI if accessed from desktop browser.

也就是说,如果从桌面浏览器访问,jQuery Mobile 是否可以自动“回退”到 jQuery UI。

采纳答案by TNC

I think it largely depends on what you want to do and functionality you're trying to capture. If you want a webpage to behave a certain way on mobile and the same desktop, then with some careful coding/testing, you'll be alright with jquery.mobile.

我认为这在很大程度上取决于您想要做什么以及您试图捕获的功能。如果您希望网页在移动设备和同一桌面上以某种方式运行,那么通过一些仔细的编码/测试,您将可以使用 jquery.mobile。

If you check out the CSS for jquery.mobile (uncompressed version), you can actually edit the code directly to show the HTML elements the way you want to for particular screen sizes. Just select the one for desktop / large screen sizes to scale appropriately.

如果您查看 jquery.mobile(未压缩版本)的 CSS,您实际上可以直接编辑代码,以针对特定屏幕尺寸以您想要的方式显示 HTML 元素。只需选择桌面/大屏幕尺寸之一即可适当缩放。

Depending on what you're trying to accomplish in terms of your mobile version, I'd also check out jQTouch- which allows for mobile-specific functionality, such as "tap" (in place of "click"), as an example - but also has a desktopCompatability option, so it reverts for desktop browsers.

根据您在移动版本方面尝试完成的工作,我还会查看jQTouch- 例如,它允许特定于移动设备的功能,例如“点击”(代替“点击”)-但也有一个桌面兼容性选项,所以它恢复为桌面浏览器。

One note, with either of these libraries, you'll still need the root jquery library.

需要注意的是,使用这些库中的任何一个,您仍然需要根 jquery 库。

Hope this helps.

希望这可以帮助。

回答by martin

First of all you will have to consider that the workflows for mobile and desktop differ vastly. Trying to flip between the desktop version and the mobile version will not be just a toggle between resources.

首先,您必须考虑到移动设备和桌面设备的工作流程有很大不同。尝试在桌面版和移动版之间切换不仅仅是资源之间的切换。

Secondly the two UI frameworks differ vastly in how they are used. jQuery UI is a collection of widgets that you can invoke when you like and where you like, it is in a sense library(ish) with a CSS framework backing it. jQuery mobile works quite differently however, by default it is a markup driven framework and to get it up and running it doesn't require you to write even 1 line of Javascript.

其次,这两个 UI 框架在使用方式上有很大不同。jQuery UI 是一组小部件,您可以在喜欢的时候和喜欢的地方调用它们,从某种意义上说,它是一个带有 CSS 框架支持的库(ish)。jQuery mobile 的工作方式完全不同,但默认情况下,它是一个标记驱动的框架,启动和运行它甚至不需要您编写 1 行 Javascript。

My advise to you is to think about the data layer as your common code and the client side as 2 completely separate pieces of work. Personally I have managed to create applications using common REST webservices. I use the jQuery UI to consume webservices and create mashups for the client-side. I then for the mobile version consume the webservices server-side to produce jQuery-mobile html pages for use on mobile.

我对您的建议是将数据层视为您的公共代码,将客户端视为 2 个完全独立的工作。我个人已经设法使用常见的 REST web 服务创建应用程序。我使用 jQuery UI 来使用 Web 服务并为客户端创建混搭。然后,对于移动版本,我使用 webservices 服务器端来生成用于移动设备的 jQuery-mobile html 页面。

Also note that generating dynamic HTML on the client side using jQuery Mobile will most certainly cause you huge headaches. Until the project matures I would use it only to enhance the frameworks highly semantic markup. Create a good solid data layer and the rest will be piss easy :)

另请注意,使用 jQuery Mobile 在客户端生成动态 HTML 肯定会让您头疼。在项目成熟之前,我只会使用它来增强框架的高度语义标记。创建一个良好的坚实数据层,其余的将很容易:)

回答by TIM

Here is the full source code: https://github.com/ti-dev/Scrum-itfor an open source Scrum Board which is designed for desktop devices and Apple iPad. So it is possible to combine these two worlds in one webpage.

以下是完整的源代码:https: //github.com/ti-dev/Scrum-it,用于为桌面设备和 Apple iPad 设计的开源 Scrum Board。因此,可以将这两个世界结合在一个网页中。