JQTouch:在“视图”之间传递数据
嗨,我今天一直在玩 jqtouch,我只是想知道如何管理数据。
我尝试环顾四周,但没有看到太多文档。
如果我有一个产品的链接列表?我点击一个可以导航到产品“视图”。如何像传递 $_GET
变量一样传递变量来选择该产品?
或者即使我将链接的 id 设置为记录的 id 并使用 JS 获取 ID 并以某种方式将其传递到下一个视图?
任何对此的帮助将不胜感激!
注意:我还想将它与离线扩展一起使用,所以我不确定 get ajax 是否有效
问候,
Billy
Hi I have been playing around with jqtouch today and I'm just wondering how to manage data.
I tried looking around but couldn't see much documentation.
If I had a list of links for say products? And I click on one i can navigate to the product 'view'. How to I pass variables like you would a $_GET
variable to select THAT product?
Or even if I set the id of the link to the id of the record and use JS to grab the ID and somehow pass it to the next view?
Any help with this would be most appreciated!
NOTE: I also want to use it with the offline extension so I'm not sure get ajax would work
Regards,
Billy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用数据对象的referrer 属性。该链接将如下所示:
其中 HTML ID 与产品 ID 相对应。然后在“pageAnimationEnd”事件中,您可以检索产品详细信息,如下所示:
You can use the referrer property for the data object. The link would look like:
where the HTML ID would correspond to the product ID. Then in the "pageAnimationEnd" event you can retrieve the product details like this:
您可以查看演示来了解它是如何进行表单提交的,即AJAX > POST 表单示例。本质上,您创建一个表单和一个 jQT 样式的提交按钮:
然后在您的接收页面(即
ajax_demo.php
)中,您可以访问表单字段,例如 PHP 的$_GET
或 JavaScript 的location.search
。另一种方法是使用 jQuery 将数据存储在 DOM 中:
You could look at the demo to see how it does form submission, i.e. AJAX > POST Form Example. Essentially, you create a form and a jQT-style submit button:
Then in your receiving page (i.e.
ajax_demo.php
), you can access the form fields, e.g. PHP's$_GET
or JavaScript'slocation.search
.Another way is to store the data in the DOM with jQuery: