jQuery Mobile:多次更新表单 [英] Jquery Mobile: updating a form more than once

查看:86
本文介绍了jQuery Mobile:多次更新表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,经过数小时的困惑,我发现在Jquery Mobile元素上调用page()仅能工作一次.

OK, after many hours of confusion I have discovered that calling page() on Jquery Mobile elements only works once.

如果我想通过AJAX多次更新表单怎么办?

What do I do if I want to update a form multiple times via AJAX?

推荐答案

更新

jQuery Mobile beta2引入了create事件..trigger('create')将JQM增强应用于元素及其子元素.

jQuery Mobile beta2 introduces a create event..trigger('create') applies JQM enhancements to an element and its children.

请参阅: http://jquerymobiledictionary.pl/faq.html

对于一个元素,您只需使用一次.尚无例外.

You have to use it only once for an element. No exceptions yet.

如果$('#container')是您的元素,并且将其内容替换为AJAX,那么您可以做两件事:

if $('#container') is your element, and you replace its content with AJAX, then there are two things you can do:

  1. $('#container').children()上呼叫.page()
  2. 清空容器并在其中创建一个div,然后在其上调用.page().
  1. call .page() on $('#container').children()
  2. empty the container and create a div inside of it, and call .page() on it.

如果您的内容需要包装(如列表),并且我通常会推荐使用第二种方法,则更好.

The second option is better if your content needs to be wrapped (like a list) and I'd recommend it in general.

如果您使用的是列表视图或其他内容,请查看.listview('refresh')或其他专用方法.

If you are using a listview or something take a look at .listview('refresh') or other dedicated methods.

这篇关于jQuery Mobile:多次更新表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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