单选按钮选择索引更改,当添加icheck.js脚本引用时不触发

radio button selected index changed not firing when icheck.js script reference is added

本文关键字:引用 脚本 js icheck 添加 索引 选择 单选按钮      更新时间:2023-09-26

aspx文件:

如果我们取消这个icheck.js引用的注释,那么事件正在触发。

  <script src="../../UI/js/icheck.js"></script>
           <asp:RadioButtonList
            ID="RadioButtonList1"
            runat="server"
            AutoPostBack="true"
            OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
            BackColor="DarkCyan"
            ForeColor="AliceBlue">
            <asp:ListItem>HyperLink</asp:ListItem>
            <asp:ListItem>LayoutEditorPart</asp:ListItem>
            <asp:ListItem>BehaviorEditorPart</asp:ListItem>
            <asp:ListItem>Localize</asp:ListItem>
            <asp:ListItem>ImageMap</asp:ListItem>
        </asp:RadioButtonList>

icheck.js在呈现为HTML单选元素时,正在给单选按钮列表应用样式。

icheck.js代码:

!function (a) {
function b(a, b, e) {
    var f = a[0], g = /er/.test(e) ? q : /bl/.test(e) ? o : m, h = e == r ? {
        checked: f[m],
        disabled: f[o],
        indeterminate: "true" == a.attr(q) || "false" == a.attr(p)
    } : f[g];
    if (/^(ch|di|in)/.test(e) && !h) c(a, g); else if (/^(un|en|de)/.test(e) && h) d(a, g); else if (e == r) for (var g in h) h[g] ? c(a, g, !0) : d(a, g, !0); else b && "toggle" != e || (b || a[x]("ifClicked"),
    h ? f[s] !== l && d(a, g) : c(a, g));
}
function c(b, c, e) {
    var k = b[0], r = b.parent(), t = c == m, u = c == q, x = c == o, y = u ? p : t ? n : "enabled", A = f(b, y + g(k[s])), B = f(b, c + g(k[s]));
    if (k[c] !== !0) {
        if (!e && c == m && k[s] == l && k.name) {
            var C = b.closest("form"), D = 'input[name="' + k.name + '"]';
            D = C.length ? C.find(D) : a(D), D.each(function () {
                this !== k && a(this).data(i) && d(a(this), c);
            });
        }
        u ? (k[c] = !0, k[m] && d(b, m, "force")) : (e || (k[c] = !0), t && k[q] && d(b, q, !1)),
        h(b, t, c, e);
    }
    k[o] && f(b, z, !0) && r.find("." + j).css(z, "default"), r[v](B || f(b, c) || ""),
    x ? r.attr("aria-disabled", "true") : r.attr("aria-checked", u ? "mixed" : "true"),
    r[w](A || f(b, y) || "");
}
function d(a, b, c) {
    var d = a[0], e = a.parent(), i = b == m, k = b == q, l = b == o, r = k ? p : i ? n : "enabled", t = f(a, r + g(d[s])), u = f(a, b + g(d[s]));
    d[b] !== !1 && ((k || !c || "force" == c) && (d[b] = !1), h(a, i, r, c)), !d[o] && f(a, z, !0) && e.find("." + j).css(z, "pointer"),
    e[w](u || f(a, b) || ""), l ? e.attr("aria-disabled", "false") : e.attr("aria-checked", "false"),
    e[v](t || f(a, r) || "");
}
function e(b, c) {
    b.data(i) && (b.parent().html(b.attr("style", b.data(i).s || "")), c && b[x](c),
    b.off(".i").unwrap(), a(y + '[for="' + b[0].id + '"]').add(b.closest(y)).off(".i"));
}
function f(a, b, c) {
    return a.data(i) ? a.data(i).o[b + (c ? "" : "Class")] : void 0;
}
function g(a) {
    return a.charAt(0).toUpperCase() + a.slice(1);
}
function h(a, b, c, d) {
    d || (b && a[x]("ifToggled"), a[x]("ifChanged")[x]("if" + g(c)));
}
var i = "iCheck", j = i + "-helper", k = "checkbox", l = "radio", m = "checked", n = "un" + m, o = "disabled", p = "determinate", q = "in" + p, r = "update", s = "type", t = "click", u = "touchbegin.i touchend.i", v = "addClass", w = "removeClass", x = "trigger", y = "label", z = "cursor", A = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
a.fn[i] = function (f, g)
{
    var h = 'input[type="' + k + '"], input[type="' + l + '"]', n = a(), p = function (b) {
        b.each(function () {
            var b = a(this);
            n = n.add(b.is(h) ? b : b.find(h));
        });
    };
    if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(f)) return f = f.toLowerCase(),
    p(this), n.each(function () {
        var c = a(this);
        "destroy" == f ? e(c, "ifDestroyed") : b(c, !0, f), a.isFunction(g) && g();
    });
    if ("object" != typeof f && f) return this;
    var z = a.extend({
        checkedClass: m,
        disabledClass: o,
        indeterminateClass: q,
        labelHover: !0,
        aria: !1
    }, f), B = z.handle, C = z.hoverClass || "hover", D = z.focusClass || "focus", E = z.activeClass || "active", F = !!z.labelHover, G = z.labelHoverClass || "hover", H = 0 | ("" + z.increaseArea).replace("%", "");
    return (B == k || B == l) && (h = 'input[type="' + B + '"]'), -50 > H && (H = -50),
    p(this), n.each(function () {
        var f = a(this);
        e(f);
        var g, h = this, n = h.id, p = -H + "%", q = 100 + 2 * H + "%", B = {
            position: "absolute",
            top: p,
            left: p,
            display: "block",
            width: q,
            height: q,
            margin: 0,
            padding: 0,
            background: "#fff",
            border: 0,
            opacity: 0
        }, I = A ? {
            position: "absolute",
            visibility: "hidden"
        } : H ? B : {
            position: "absolute",
            opacity: 0
        }, J = h[s] == k ? z.checkboxClass || "i" + k : z.radioClass || "i" + l, K = a(y + '[for="' + n + '"]').add(f.closest(y)), L = !!z.aria, M = i + "-" + Math.random().toString(36).substr(2, 6), N = '<div class="' + J + '" ' + (L ? 'role="' + h[s] + '" ' : "");
        L && K.each(function () {
            N += 'aria-labelledby="', this.id ? N += this.id : (this.id = M, N += M), N += '"';
        }), N = f.wrap(N + "/>")[x]("ifCreated").parent().append(z.insert), g = a('<ins class="' + j + '"/>').css(B).appendTo(N),
        f.data(i, {
            o: z,
            s: f.attr("style")
        }).css(I), !!z.inheritClass && N[v](h.className || ""), !!z.inheritID && n && N.attr("id", i + "-" + n),
        "static" == N.css("position") && N.css("position", "relative"), b(f, !0, r), K.length && K.on(t + ".i mouseover.i mouseout.i " + u, function (c) {
            var d = c[s], e = a(this);
            if (!h[o]) {
                if (d == t) {
                    if (a(c.target).is("a")) return;
                    b(f, !1, !0);
                } else F && (/ut|nd/.test(d) ? (N[w](C), e[w](G)) : (N[v](C), e[v](G)));
                if (!A) return !1;
                c.stopPropagation();
            }
        }), f.on(t + ".i focus.i blur.i keyup.i keydown.i keypress.i", function (a) {
            var b = a[s], e = a.keyCode;
            return b == t ? !1 : "keydown" == b && 32 == e ? (h[s] == l && h[m] || (h[m] ? d(f, m) : c(f, m)),
            !1) : void ("keyup" == b && h[s] == l ? !h[m] && c(f, m) : /us|ur/.test(b) && N["blur" == b ? w : v](D));
        }), g.on(t + " mousedown mouseup mouseover mouseout " + u, function (a) {
            var c = a[s], d = /wn|up/.test(c) ? E : C;
            if (!h[o]) {
                if (c == t ? b(f, !1, !0) : (/wn|er|in/.test(c) ? N[v](d) : N[w](d + " " + E), K.length && F && d == C && K[/ut|nd/.test(c) ? w : v](G)),
                !A) return !1;
                a.stopPropagation();
            }
        });
    });
};

}(窗口。jQuery || window.Zepto);

我面临的问题,我使用jquery修复它

$('.iCheck-helper').on('click', function (event) {
  var mapper = $(this).siblings().find('input[type=radio]');
  $('#' + $(mapper.prevObject).attr('id')).trigger("click");
});

。Icheck-helper是由插件自动生成的类