Commit 34404816 authored by Amir.h Yeganemehr's avatar Amir.h Yeganemehr

one-select fix for radio inputs

parent 39a93918
......@@ -3,14 +3,23 @@
import * as $ from "jquery";
$.fn.bootstrapCheckbox = function(){
function setClasses(){
const $label = $(this).parents("label");
const checked: boolean = $(this).prop("checked");
const $this = $(this);
const $label = $this.parents("label");
const checked: boolean = $this.prop("checked");
const isRadio: boolean = $this.attr("type").toLowerCase() === "radio";
if (checked){
if (!$label.hasClass("checked")){
$label.addClass("checked");
}
if (isRadio) {
const $form = $this.parents("form");
const name = $this.attr("name");
const $others = $(`input[name="${name}"][type=radio]`, $form).not($this);
$others.prop("checked", false);
$others.parents("label").removeClass("checked");
}
$label.removeClass("indeterminate");
}else{
}else if (!isRadio) {
$label.removeClass("checked");
const indeterminate: boolean = $(this).prop("checked");
if (indeterminate){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment