jQuery Mobile破坏了我的网站 [英] jQuery Mobile breaks my site

查看:98
本文介绍了jQuery Mobile破坏了我的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在移动触摸屏设备上时,我在网站上加载了jQuery Mobile.当我这样做的时候.它弄乱了一切.例如,选择菜单无法正常工作,页面底部也会显示正在加载,正在加载,未定义"字样.我知道我缺少什么,但不知道什么.

I load jQuery Mobile on my site when I am only on a mobile touchscreen device. When I do though. It messes up everything. For example, select menus don't work quite right, as well, the words "loading, loading, undefined" appear at the bottom of the page. I know I am missing something but do not know what.

关于我可能会缺少的任何想法吗?

Any ideas on what I could be missing?

谢谢

好的,所以我取出了我正在运行的所有脚本,除了jQuery和jQuery Mobile.我先叫jQuery,然后叫jQuery Mobile.仍然破坏了网站的各个方面.

Okay, So I took out all scripts that I am running except for jQuery and jQuery Mobile. I call jQuery first, then jQuery Mobile. It still breaks aspects of the site.

中断之处: -我无法通过导航栏导航到任何其他页面,如果单击导航项目,然后查看网址,则会显示正确的网址(其中带有#),例如:/#/about-us/然后,它只是重定向到主页,页面变为白色

What it breaks: - I cannot navigate to any other page via the navbar, if I click on a nav item, and look in the url, the correct url appears (with a # in it) like: /#/about-us/ Then, it just redirects to the home page and the page goes white

  • 选择菜单的结果很奇怪.它会打印出其旁边的选择项中的任何内容.而且,如果您在ipad上处于横向模式,然后单击选择,它将把您带到页面底部(很奇怪).

  • Select menus have weird results. It prints out whatever is in the select right beside it. And if you in landscape mode on the ipad and you click on the select, it sends you to the bottom of the page (weird).

它在页面底部打印两次正在加载",并输出一次未定义"

it prints out 'loading' twice and 'undefined' once at the bottom of the page

我所拥有的所有脚本都是jQuery和jQuery Mobile.我还应该提到我正在使用wordpress,因此它可能已经加入了其他一些脚本(我已经注销了Wordpress版本的jquery并加入了我自己的队列)

All I have for scripts are jQuery and jQuery Mobile. I should also mention that I am using wordpress so it might have enqueued some other scripts (I have deregistered Wordpress' version of jquery and enqueued my own)

还有其他人遇到这些问题吗?

Anyone else experiencing these problems?

推荐答案

jQueryMobileAjax替换常规链接,因此每个页面都可以由ajax加载,文档页面上的文本为

jQueryMobile replace your normal links with Ajax one, so every page can be loaded by the ajax, text on docs page:

(..) Ajax is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler only executes for the first page. To execute code whenever a new page is loaded and created, you can bind to the pageinit event. This event is explained in detail at the bottom of this page.

如果要禁用ajax加载单个链接,则应编写如下内容:

If you want to disable single link to be loaded by the ajax you should write something like this:

<a href="/some_page" data-ajax="false" >link</a>

或全局执行:

$(document).bind("mobileinit", function() {
  $.mobile.ajaxEnabled = false;
});

jm还会替换其他元素,因此您应该尝试使用data-role属性,例如:

jm also does replacement on other elements so you should try using data-role attribute, for example:

<select id="test" data-role="none">

禁用替换此元素.

这篇关于jQuery Mobile破坏了我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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