Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Mobile Fast Radio Buttons
    primarykey
    data
    text
    <p>Another topic on the much discussed issue of button responsiveness when web apps are used on mobile devices.</p> <p>I am listening for the <code>touchend</code> event to trigger a radio button being pressed. This solves the issue of making the button more responsive, however creates another problem.</p> <p>jQuery mobile applies classes such as <code>ui-icon-radio-on</code>, <code>ui-radio-on</code>, <code>ui-btn-hvr-a</code>, <code>ui-btn-dwn-a</code> when the event occurs that get left behind. This makes the button look like it is still being pressed even though the event is over. It ends up being a decent effort to juggle removing and adding all those classes to make everything look right.</p> <p>My questions is - does anyone have an elegant way of adding and removing the needed classes and attributes.</p> <p>or</p> <p>Is there a better way of going about this that will not involve "recreating the wheel" in terms of manually dealing with the styling based on event triggers. Would google's fast button be a better solution? (not sure how to integrate). Is there a simpler way?</p> <pre><code>$(document).on('pageinit pageshow', 'div:jqmData(role="page"), div:jqmData(role="dialog")', function (event) { if($(this).hasClass('AdminSurv') &amp;&amp; event.type=='pageinit') { $(this).on( 'touchend', '.ui-radio', function(event) { event.preventDefault(); /*uncheck all radios in control group to avoid multiple checks*/ var _control_group = $(this).parent(); _control_group.find("input:radio:checked").attr('checked',false); /*check the radio*/ $(this).find('input').attr('checked', true); /*much juggling of classes/attributes going on here still looks like the buttons are being held down this is a very sloppy example of my initial attempt*/ _control_group.find('label').removeClass('ui-radio-on'); _control_group.find('label').removeAttr('data-icon'); _control_group.find('label span span').removeClass('ui-icon-radio-on'); $(this).find('label').removeClass('ui-radio-off'); $(this).find('label').addClass('ui-radio-on'); $(this).find('label').attr('data-icon','radio-on'); $(this).find('label span span').removeClass('ui-icon-radio-off'); $(this).find('label span span').addClass('ui-icon-radio-on'); }); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload