开发者

Jquery Mobile: updating a form more than once

OK, afte开发者_JAVA百科r 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜