Philipp Siegfried
Philipp Siegfried

Reputation: 986

Reinitialize jquery-mobile after inserting a form into the page

I'm inserting a form via ajax dynamically into the page. After inserting it into the dom tree, i would like to reinitialize the jquery mobile to style the form. I had a look into http://jquerymobile.com/test/docs/api/events.html but since the documentation is pretty unhelpful for jquery mobile I'm not able to find the correct event.

Upvotes: 2

Views: 3143

Answers (1)

Jasper
Jasper

Reputation: 76003

After you have added the form to the DOM, use .trigger('create'); on the form to initialize any widgets (form elements) you've just added:

...html('<form><input data-role="slider" type="text" /><input type="button" value="button" /></form>').trigger('create');

Here is a demo: http://jsfiddle.net/TBRXk/

Upvotes: 8

Related Questions