jQuery Mobile的页面丢失JavaScript文件 [英] jQuery Mobile page loses JavaScript file

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

问题描述

嘿,伙计们有jQuery Mobile的一个真正的问题,我试图修复,但我:-(失败 我有一个导航浏览低谷我的应用程序,如果我点击这是关系到一个网站,其中有一个js文件做一些功能的链接,.js文件丢失。如果我看萤火,我没有看到在我的-section我指定的GET-标记id.js - code。如果我刷新页面,则.js文件出现,一切都很好,所有的功能被发现并正常工作。

hey guys have a real problem with jQuery Mobile, I've tried to fix but I've failed :-( I have a Navigation to browse trough my app and if I click on a link which is related to a site, which has a .js file for doing some functions, the .js file is lost. If I look at firebug, I don't see my specified "get-marker-id.js" in the -section of my -code. If I refresh the page, the .js file appears and all is fine, all functions were found and work perfectly.

作为一种解决办法我figuered指出,给航行-tag的相对=外部属性解决了这个问题,因为该网站是完全不加载从阿贾克斯呼叫。

As a workaround I figuered out that to give the -Tag of the Navigation an rel=external attribute solves this problem because the site is loaded completely and not from an ajax call.

现在我想知道如果我能解决这个问题有更好的解决方法吗?因为如果我使用相对=外部移动Safari浏览器打开一个新的标签,如果我救了页到我的主屏幕,这就是我的客户不希望=( 。我非常感谢帮助: - )

Now I want to know if I can solve the problem with an better workaround ? Because if I use the "rel=external" the mobile Safari opens a new Tab, if I had saved the Page to my homescreen and this is what my customers not want =(. I'm very thankful for help :-)

推荐答案

如果我们presume,我们正在从简单,的从jQuery Mobile的单页模板,有一种被冷落的信息的键位。如果你想拥有全球可用的函数和变量,能够改变框架的默认值,则需要到的jquery.js和jquerymobile.js作为节目之间添加自定义脚本,在他们的全局配置页面

If we presume that we're starting from the simple, single page template from jquery mobile, there is a key bit of information that is left out. If you want to have globally available functions and variables and be able to alter the defaults of the framework, you need to add your custom script between the jquery.js and the jquerymobile.js as show on their global configurations page.

<head>
    ...
    <script src="jquery.js"></script>
    <script src="custom-scripting.js"></script>
    <script src="jquery-mobile.js"></script>
    ...
</head>

当你从一个页面转到下一个具有内置的基于AJAX导航,一切都在定制scripting.js依然会提供给你,甚至可以用来操纵网页作为他们进入。

As you go from one page to the next with the built in ajax based navigation, everything in the custom-scripting.js will still be available to you and can even be used to manipulate the pages as their coming in.

不过,如果你把一个脚本,你的&LT内; DIV数据角色=页面&GT; ,你将有机会获得只执行,只要是页面到位。一旦您导航到另一个页面,即初始页面会从DOM中删除,因此你的脚本。因此,你需要或者调用脚本中的每一页上,或放入定制的script.js。使用全局脚本是因为在移动的http请求一个更高性能的选择是什么原因大部分怠工的。

If, however, you place a script inside of your <div data-role="page"> you will have access to execute only so long as that page is in place. Once you navigate to another page, that initial page would be removed from the DOM and thus your script. You would therefore need to either call in your script on every page or put it into the custom-script.js. Using the global script would be a far more performant option since http requests in mobile are what cause most of the slowdowns.

这篇关于jQuery Mobile的页面丢失JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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