JQuery Mobile和Firefox不能很好地一起玩? [英] JQuery Mobile and Firefox don't play well together?

查看:154
本文介绍了JQuery Mobile和Firefox不能很好地一起玩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery Mobile中存在一些问题。想知道是否其他人在使用Firefox(桌面)时遇到了一些错误,并让jQuery Mobile脚本在< head> 中包含如下内容:

 < script src =http://code.jquery.com/jquery-1.9.1.min.js> ;< /脚本> 
< script src =http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js>< / script>

在Chrome和Firefox中,我都会遇到大量CSS错误,我认为这些错误可以忽略不计。但在Firefox中,我收到了几个JS错误,这似乎也打破了我的页面(响应元素没有像我删除jQuery Mobile脚本时那样呈现)。



JS错误:

 传递给getElementById()的空字符串。 @ http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.js:11100 
不推荐使用getPreventDefault()。改为使用defaultPrevented。 @ http://code.jquery.com/jquery-1.9.1.js:3346

I知道错误似乎很详细,但我不熟悉笨拙的JavaScript插件和他们的优雅退化政策。其他人有这个问题?



更新



根据Tim的回答,已经证明了这些jQuery Mobile'警告'实际上正在影响页面的证据。以下是我评论jQuery Mobile脚本标签时的页面:



以下是当jQuery Mobile脚本标签留在时页面的样子:





请注意,我想使用jQuery Mobile的原因纯粹是因为它是移动触摸/滑动事件。我没有兴趣采用它的哈希/ ajax链接功能。

解决方案

是的,jQuery Mobile在混乱DOM时它已加载。例如,jQuery Mobile会将您的内容封装在pagediv中: b
$ b


在幕后,框架将注入页面包装器if它的
不包含在标记中,因为它需要管理页面
Pages - jQuery Mobile Docs


但是你可以看到它是CSS还是Javascript这是通过一次仅包含一个jQuery Mobile位来打破您的网站。



我也对 getElementById (),我可以确认它只是一个警告,不会影响布局。 我曾问过如何摆脱这个问题警告,但无济于事。



最后,您是否尝试过使用 jQuery Mobile的自定义构建器,以获取您感兴趣的部分(即触摸功能)?


Having some teething issues with jQuery Mobile. Was wondering if anybody else is experiencing a smattering of errors when they're using Firefox (desktop) and have the jQuery Mobile script includes in their <head> like so:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

In both Chrome and Firefox I get a host of CSS errors, which I presume are negligible. But in Firefox I get a couple of JS errors on top of that, which also seems to break my page (responsive elements not rendering like they would when I remove the jQuery Mobile script).

The JS errors:

Empty string passed to getElementById(). @ http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.js:11100
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. @ http://code.jquery.com/jquery-1.9.1.js:3346

I know the errors seem pretty verbose, but I'm not familiar with bloaty javascript plugins and their policy on graceful degradation. Anyone else having this issue?

Update

As per Tim's answer, I've snapshotted evidence that these jQuery Mobile 'warnings' are actually effecting the page. Below is the page when I comment the jQuery Mobile script tags out:

And here is what the page looks like when the jQuery Mobile script tags are left in:

Note that the reason I wanted to use jQuery Mobile is purely for it's mobile touch/swipe events. I have no interest in adopting it's hash/ajax linking functionality.

解决方案

Yes, jQuery Mobile does "mess with the DOM" when it's loaded. For example, jQuery Mobile will wrap your content in a "page" div:

Behind the scenes, the framework will inject the page wrapper if it's not included in the markup because it's needed for managing pages (Pages - jQuery Mobile Docs)

But you could see if it's the CSS or the Javascript that's breaking your site by including only one of the jQuery Mobile bits at a time.

I too am getting the same warning regarding the call to getElementById(), and I can confirm that it is just a warning and does not impact layout. I have asked specifically about getting rid this warning, but to no avail.

Finally, have you tried using jQuery Mobile's custom builder to get just the parts you are interested in (i.e. the touch features)?

这篇关于JQuery Mobile和Firefox不能很好地一起玩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆