Jquery Mobile: updating a form more than once

こ雲淡風輕ζ 提交于 2019-12-19 11:27:44

问题


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

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


回答1:


update

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

See: http://jquerymobiledictionary.pl/faq.html


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

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

  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.

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




回答2:


After several workarounds that did not meet my needs, I found this particular statement: remove or overwrite an existing div and call .page() on new div. This works best if content has to be reloaded / re-rendered / refreshed more than once.



来源:https://stackoverflow.com/questions/5362127/jquery-mobile-updating-a-form-more-than-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!