MonOve
MonOve

Reputation: 1101

Using specific elements of jQuery Mobile and not others

Is there any way of using jQuery Mobile for only certain features such as toggle on/off switches but not have it take over the entire CSS?

Upvotes: 3

Views: 1521

Answers (2)

Jasper
Jasper

Reputation: 75993

You can set this per element with a data-role="none" attribute on the element or bind to the mobileinit event like so:

$(document).bind('mobileinit',function(){
    $.mobile.page.prototype.options.keepNative = "select, input.foo, textarea.bar";
});

Notice how you can add classes to the selectors.

From the docs:

Or, if you'd like to prevent auto-initialization without adding attributes to your markup, you can customize the selector that is used for preventing auto-initialization by setting the page plugin's keepNative option (which defaults to [data-role="none"]. Be sure to configure this option inside an event handler bound to the mobileinit event, so that it applies to the first page as well as subsequent pages that are loaded.

Docs on this can be found here: http://jquerymobile.com/demos/1.0rc2/docs/forms/docs-forms.html

Upvotes: 1

Related Questions