This is a slightly different approach to the end problem (and might not be useful to anyone), but I needed a step that allowed for even numbers only (i.e. step="2"). I also needed the slider/range input to work well both on desktop and mobile because I'm like that. I found that by binding to the change event (versus various tap or tapholds on the generated UI elements, which always feels kind of stinky) and doing my rounding there, I could alter the value fast enough that the user only ever saw the "legal" ones as they slide the slider around. That way I don't have to hack core or whatever. My code looks like this:
- <li class="size-input" data-role="fieldcontain">
- <label for="size-1">Stitch Count</label>
- <input id="size-1" type="range" min="2" step="2" max="72" autocomplete="false" name="sizes[]" value="" placeholder="Size" />
- </li>
- (function() {
- $('[data-role="page"]').live('pagecreate', function () {
- $('#size-1').change(onThingSizeChange);
- });
- function onThingSizeChange(changeEvent) {
- var current_val = parseInt($('#size-1').val(), 10);
- if (current_val % 2 == 1) {
- $sizeSlider.val(current_val + 1);
- }
- }());
Tested on desktop Chrome, iPhone 4, Nexus One. Not exactly the full gamut of devices.
(p.s. I get that this approach might not work for fractional steps. But you might be able to riff off of it).