jquery - On iOS Safari, using radio button to toggle dom breaks radios/checkboxes -


the following code works fine on browsers except safari on ios (haven't tested android yet).

simple enough concept. when user clicks radio option, toggle class change additional fields shown. works first time, after change once, radio buttons , checkboxes become unclickable.

here's code looks like..
html:

<div class="form-group col-xs-12 checklist patientorother">   <p>will cd going (the patient) or facility/clinician?</p>   <label for="patient"><input type="radio" name="topatientorother" id="patient" value="patient" checked>to patient (myself)</label>   <label for="other"><input type="radio" name="topatientorother" id="other" value="other">to facility/clinician</label> </div> <div class="topatient">   <p>info needed when going patient</p> </div> <div class="toother hide">   <p>info needed when going facility/clinician</p> </div> 

jquery:

$('#patient').bind('change', function() {   if ($(this).is(':checked')) {     $('.toother').addclass('hide');     $('.topatient').removeclass('hide');   } }); $('#other').bind('change', function() {   if ($(this).is(':checked')) {     $('.topatient').addclass('hide');     $('.toother').removeclass('hide');   } }); 

i've tried using other methods of binding event, such .on('click', function() {});, .change(), etc. still same result on ios safari.

working @ https://jsfiddle.net/pc5n3tg0. tested on ios 8.1 , note use of jquery 2.1.3. may worth editing question reflect versions, may require more investigation.
solution uses on('click') , sets hide. presuming css

.hide {     display:none; } 

js

$('#patient').on('click', function () {     if ($(this).is(':checked')) {         $('.toother').addclass('hide');         $('.topatient').removeclass('hide');     } }); $('#other').on('click', function () {     if ($(this).is(':checked')) {         $('.topatient').addclass('hide');         $('.toother').removeclass('hide');     } });` 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -