0

I'm aware that if I use jQuery Mobile, it will effect all elements on a page, except for elements I add data-role="none" to.

Is there a way to have jQuery Mobile effect nothing except for the elements I wish to opt-in?

0

1 Answer 1

1

See ignoreContentEnabled

Once set, all automatic enhancements made by the framework to each enhanceable element of the user's markup will first check for a data-enhance=false parent node. If one is found the markup will be ignored. This setting and the accompanying data attribute provide a mechanism through which users can prevent enhancement over large sections of markup.

You can implement like so:

$( document ).on( "mobileinit", function() {
  $.extend( $.mobile , {
    ignoreContentEnabled: true
  });
});
3
  • Hi, So, I believe I add this to the top of my page before jQuery Mobile loads. Do you know what the next step is? I don't understand what the "data-enhance=false parent node" is. I was hoping the process would be like: 1) Globally tell jQueryMobile to effect nothing by default. 2) add something such as data-role="on" for elements you want it to effect. I'm a little confused if the process described in ignoreContentEnabled is describing a similar process or not.
    – Chain
    Nov 20, 2014 at 2:23
  • It will check parent nodes for data-enhance="false". If it finds one, the node in question will be ignored by jQuery mobile.
    – Tomanow
    Nov 20, 2014 at 2:27
  • If I understand that correctly, I should add data-enhance="false" to something like the 1st main sections div tag, and then for a theoretical 2nd section where I want jQueryMobile to effect, I don't put anything. Essentially, it's like a data-role="none" that works on parent elements. Do I have that correct?
    – Chain
    Nov 20, 2014 at 3:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.