用jQuery Mobile在页面之间传递数据? [英] Passing data between pages with jQuery Mobile?
问题描述
我认为JQM最酷的一件事就是您不必使用参数在页面之间传递数据。由于您与第一页位于同一个DOM,因此您可以使用普通的旧变量来访问数据,即
field1 = $ ( '[名= FIELD1]')VAL();
field2 = $('[name = field2]')。val();
只要您使用JQM的ajax功能,您可以在下一步执行以下操作page:
$('。title')。text(field1);
我制作了一个jsfiddle示例。
其他方法是使用localStorage或sessionStorage API,或者也提到一些插件在文档中。
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.
这篇关于用jQuery Mobile在页面之间传递数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!