JQuery Mobile is making my cry tonight. I\'m trying to build custom controls so I don\'t repeat certain elements through my app, and it\'s giving me a hard time. Specifica
this question is old enough by now, but I just ran into the problem so here is how I handled it -- (this maintains the set data-theme and applies the correct roles for the containing divs and headers)
$('your_selector').find('div[data-role="header"], div[data-role="footer"]').each(
function( ){
var dR = $(this).attr('data-role');
var dT = $(this).attr('data-theme');
$(this).addClass('ui-' + dR + ' ui-bar-' + dT).attr('role', (dR == 'header' ? 'banner' : 'contentinfo') ).children('h1, h2, h3, h4').each(
function( ){
$(this).addClass('ui-title').attr({'role':'heading', 'aria-level':'1'});
}
)
}
);
depending on your code, it might be more convenient to set this up as a function and send your selector as an argument. Hope it helps.