复选框显示不会随 jquery 改变

发布于 2024-12-24 03:47:27 字数 706 浏览 3 评论 0原文

我有一些值从子表单发回父表单并触发此方法,

function OnClientClose(oWnd, args) {
    //get the transferred arguments
    var arg = args.get_argument();
    if (arg) {
        var agreementId = $find("<%= rtxtAgreementId.ClientID %>");
        var legacyReinsurerId = $find("<%= rtxtlegacyReinsurerId.ClientID %>");

        agreementId.set_value(arg.ReinsuranceAgreementId);
        legacyReinsurerId.set_value(arg.LegacyReinsurerId);
        $("<%= chkCommutationFlag.ClientID %>").prop("checked", Boolean(arg.CommutationFlag));
    }
};

所有参数都具有正确的值,包括 Boolean(arg.CommutationFlag),因为我通过在文本框中显示值来测试这一点,但我的复选框显示值确实如此不改变。我尝试了各种方法来设置复选框值,它们都在处理时不会抛出错误,但复选框仍处于未选中状态。我缺少什么?

I have some values that post back to a parent form from a child form and fire this method

function OnClientClose(oWnd, args) {
    //get the transferred arguments
    var arg = args.get_argument();
    if (arg) {
        var agreementId = $find("<%= rtxtAgreementId.ClientID %>");
        var legacyReinsurerId = $find("<%= rtxtlegacyReinsurerId.ClientID %>");

        agreementId.set_value(arg.ReinsuranceAgreementId);
        legacyReinsurerId.set_value(arg.LegacyReinsurerId);
        $("<%= chkCommutationFlag.ClientID %>").prop("checked", Boolean(arg.CommutationFlag));
    }
};

all arguments have the proper values including Boolean(arg.CommutationFlag) as I tested this by displaying the value in a textbox, but my checkbox display value does not change. I have tried various methods to set the checkbox value and they all process without throwing an error but the checkbox remains unchecked. What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹倦 2024-12-31 03:47:27

首先检查您是否确实达到了目标,用一些普通的 css 替换 prop 来查看复选框是否改变了外观。
如果没有,您的 ID 就是错误的,请记住,您需要在 ID 前加上 #。
如果它确实发生了变化,请将您的布尔值替换为实际的单词“true”,如果解决了它,则您的布尔值是错误的,并且可能是其中之一。

只是为了确保您可以在复选框代码上方放置一个警报,以查看您的脚本是否已完成,但如果控制台没有显示错误,并且 css 方法有效,那就不是这样了。

Start by checking if you are actually hitting the target, replace prop with some mundane css instead to see if the checkbox changes apperance.
If it does'nt your ID is wrong, and remember that you need # before the ID.
If it does change, replace your boolean with the actual word "true", if that fixes it your boolean is wrong, and it's probably one or the other.

Just to make sure you could place an alert right above your checkbox code to see that your script is getting that far, but if the console shows no errors, and if the css approach works, that's not it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文