Here is the context - I am attempting to create an adaptive design where select boxes appear as jQuery Mobile selects on large screens and as MobiScroll selects on small screens. The original select in the HTML is written up like this
<select data-mini='true' data-inline='true' class='variants' data-role='none' style='display:none'>
<option value='1'>Small</option>
<option value='2'>Medium</option>
<option value='3'>Large</option>
</select>
The
style='display:none'
bit is critical. Without it you end up with two controls on small screens - once the original select and then the mobiscroll styled select. This is not too well explained in the MobiScroll documentation.
In my document.ready code I put in something along the lines of
if (600 > $(window).width()) {
$('.variants').scroller({
preset: 'select',
theme: 'android-
ics',
rows: 1,
mode: 'scroller',
display: 'inline',
inputClass: 'i-txt',
showLabel: false,
width: 40,
height: 20
});
} else {
$('.variants').css('display', 'inline-block').removeData('role');
}
With this in place an unstyled browser select box shows up on large screens. I am attempting to take out the data-role bit via removeData because I want the select to appear as a jQuery Mobile select which is a whole lot prettier. However, this is not happening and removeData is not doing a thing. What I am doing wrong?