Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to regenerate jQuery Mobile style after Ajax request?

I'd like to apply autogenerated jQuery Mobile style (classes jQuery Mobile applies on page loading) after additionnal content loading via Ajax.

I load some content via Ajax which is parsed and organised into a <ul>, but the style jQuery usually applies on page loading isn't applied again on the Ajax loaded content.

like image 788
Alexandre Bourdin Avatar asked Jan 26 '11 14:01

Alexandre Bourdin


People also ask

How do you refresh modal after Ajax success?

Just reload the header.

Does AJAX work on mobile?

This is website works fine on any desktop browser but does not work on any mobile browser.

How can I tell if Ajax request is complete in asp net?

Previously, ASP.NET MVC applications could easily check if a request was being made via AJAX, through the aptly named IsAjaxRequest() method which was an available method on the Request object, as shown below: public ActionResult YourActionName() { // Check if the request is an AJAX call.


2 Answers

Assuming your ul is a jquery-mobile "listview", try to refresh the entire list by using :

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

jQuery Mobile doucmentation http://jquerymobile.com/demos/1.0a2/#docs/forms/plugin-eventsmethods.html

like image 103
Cyril Avatar answered Oct 21 '22 15:10

Cyril


I was having troubles with this refresh method as well, got it working after a bit more searching by removing 'refresh', ie :

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

Found with explanation at http://forum.jquery.com/topic/wish-listview-refresh-would-go-away. Works ok in 1.1.1

like image 28
Samson Avatar answered Oct 21 '22 14:10

Samson