javascript - When using bootstrap Radio without preselecting an option, the first option result checked even if nothing is -


i'm trying use bootstrap radio using following markup , js

<div class="form-control type">     <div class="radio-header">please select type of gallery item want create</div>     <div class="btn-group" data-toggle="buttons">         <label class="btn btn-primary">             <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_image_0" value="image" name="dgt_gallery_item[0][type]" />image</label>         <label class="btn btn-primary">             <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_quote_0" value="quote" name="dgt_gallery_item[0][type]" />quote</label>         <label class="btn btn-primary">             <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_text_0" value="text" name="dgt_gallery_item[0][type]" />text</label>         <label class="btn btn-primary">             <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_video_0" value="video" name="dgt_gallery_item[0][type]" />video</label>     </div> </div>      $( '#gallery_items .admin-card' ).each( function( index, element ) {         var name = $( 'input:radio:first', ).attr( 'name' );         var type = $(' input[name="' + name + '"]:checked',this ).val();         switch_visibility_of_gallery_fields_by_type( type, );     } ); 

.admin-card parnet field contains many form inputs. see no option preselected in html, in jquery, on firefox, first radio results checked. true in bootstrap selecting first option doesn't trigger "change" event. works expected in chrome 64 windows. idea on use on firefox?i need value of first checked radio or undefined if no radio checked.

firefox persists form control states (disabledness , checkedness) across page loads. workaround use autocomplete="off".

try adding autocomplete="off" input fields.

<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_image_0" value="image" name="dgt_gallery_item[0][type]" autocomplete="off" /> 

Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

asp.net mvc - Cannot display error message on Editor or EditorFor -

php - Using str_replace to translate a MySQL Table in html -