最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery-mobile : force jquery mobile initialization? - Stack Overflow

programmeradmin2浏览0评论

I'm developing a web site with jquery mobile. My main page displays a list of items, but I catch those items with an ajax function, and then build HTML document in javascript

The problem is that jQuery Mobile initialize the page before I can modify the page, so the page doesn't look in jqm style. How can I force jqm to 'rebuild' the page after my modifications ?

Thanks

I'm developing a web site with jquery mobile. My main page displays a list of items, but I catch those items with an ajax function, and then build HTML document in javascript

The problem is that jQuery Mobile initialize the page before I can modify the page, so the page doesn't look in jqm style. How can I force jqm to 'rebuild' the page after my modifications ?

Thanks

Share Improve this question asked Sep 1, 2011 at 13:20 Stéphane PietteStéphane Piette 5,4316 gold badges36 silver badges50 bronze badges 1
  • I think wich you need execute your ajax function inside a pageshow jMobile event. :] – Rael Max Commented Sep 1, 2011 at 14:53
Add a ment  | 

1 Answer 1

Reset to default 5

If you want to be able to adjust the DOM before the JQuery Mobile initialization occurs I suggest you do the following:

$('#YourPagesId').live('pagebeforecreate',function(event){
  // All of your DOM modification goodness here.
});

If you want to modify the DOM after the initial JQuery Mobile initialization has occurred then you would need to fire the appropriate event.

(The examples below are with a list view)

On creation of a new list view do the following:

$('#ListViewsId').listview();

If you are just modifying an already initialized listview do this:

$('#ListViewsId').listview('refresh');

More information about the available event like 'pagebeforecreate' can be found here: JQuery Mobile Events

More informration on how to initialize and refresh a JQuery Mobile Widget can be found here: Create vs. refresh: An important distinction

发布评论

评论列表(0)

  1. 暂无评论