用jQuery Mobile在页面之间传递数据? [英] Passing data between pages with jQuery Mobile?

查看:100
本文介绍了用jQuery Mobile在页面之间传递数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚刚开始学习jQuery Mobile,并且我已经了解到如何通过ajax加载所有链接,而无需实际加载下一页。我的几个页面使用表单和GET将数据传递到下一页 - 我如何在使用jQuery Mobile时执行此操作?

解决方案

我认为JQM最酷的一件事就是您不必使用参数在页面之间传递数据。由于您与第一页位于同一个DOM,因此您可以使用普通的旧变量来访问数据,即

  field1 = $ ( '[名= FIELD1]')VAL(); 
field2 = $('[name = field2]')。val();

只要您使用JQM的ajax功能,您可以在下一步执行以下操作page:

  $('。title')。text(field1); 

我制作了一个jsfiddle示例



其他方法是使用localStorage或sessionStorage API,或者也提到一些插件在文档中。


  1. page params

  2. JQM路由器插件


So I've just started learning jQuery Mobile, and I've learned how it loads all links via ajax without actually loading the next page. Several of my pages use forms and GET to pass data on to the next page-- How can I do this while using jQuery Mobile?

解决方案

One thing that I think is cool about JQM is that you don't have to use parameters to pass data between pages. Since you're in the same DOM as the first page, you can access data using plain old variables, i.e.

field1 = $('[name=field1]').val();
field2 = $('[name=field2]').val();

And so long as you're using the ajax feature of JQM you could do the following in the next page:

$('.title').text(field1);

I made a jsfiddle example for you.

Other ways would be to use the localStorage or sessionStorage api or there are also some plugins mentioned in the docs.

  1. page params
  2. JQM router plugin

这篇关于用jQuery Mobile在页面之间传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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