是否确定传递变量通过url在phonegap? [英] is it ok to pass variable through the url in phonegap?

查看:151
本文介绍了是否确定传递变量通过url在phonegap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 在创建jquery mobile / phonegap应用程序时,可以通过URL将变量传递到另一个页面

page.html?var1 = foo& var2 = bar

代码?

解决方案

将变量传递到外部页面应该很好。只需知道网址变量只会传递到外部网页。这意味着如果您已经在DOM中有一个外部页面,您将不得不重新加载页面以再次传递它的变量。



我相信旧版本的jQuery



也请阅读本页底部的已知限制: http://jquerymobile.com/demos/1.1.0-rc。 1 / docs / pages / page-navmodel.html (特别是底部的第二个项目符号)



更新



要使用jQuery Mobile重新加载页面,您可以使用 $。mobile.changePage()函数并设置 reloadPage 选项 true

  $(document)。 delegate('#my-link-id','click',function(){
$ .mobile.changePage({reloadPage:true});
return false;
}

文件: http://jquerymobile.com/demos/1.1.0-rc.1/docs/api/methods.html


When creating a jquery mobile / phonegap app, is it ok to pass variables through the url from one page to another

page.html?var1=foo&var2=bar

or is does it create a problem when compiling the code?

解决方案

It should be just fine to pass variables to external pages. Just know that URL variables will only be passed to external pages. Meaning that if you already have an external page in the DOM, you will have to re-load the page to pass it variables again.

I believe that older versions of jQuery Mobile hamper this behavior but you should be good to go with anything 1.0 or later.

Also read the bottom of this page, "Known Limitations": http://jquerymobile.com/demos/1.1.0-rc.1/docs/pages/page-navmodel.html (specifically the second from the bottom bullet)

Update

To reload a page with jQuery Mobile you can use the $.mobile.changePage() function and set the reloadPage option to true:

$(document).delegate('#my-link-id', 'click', function () {
    $.mobile.changePage({ reloadPage : true });
    return false;
});

Docs: http://jquerymobile.com/demos/1.1.0-rc.1/docs/api/methods.html

这篇关于是否确定传递变量通过url在phonegap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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