This is a migrated thread and some comments may be shown as answers.

Want to only check checkbox after confirm

2 Answers 237 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Harry
Top achievements
Rank 1
Harry asked on 11 Jun 2014, 03:58 PM
I have a checkbox defined as

<telerik:RadButton ID="checkbox1" runat="server" Text="testing" ButtonType ="ToggleButton" ToggleType="CheckBox" OnClientClicked="checkbox1_ClientClicked"></telerik:RadButton>

What I want to do in the ClientClicked event is only check the box (and uncheck a different checkbox) when the user selects OK. Everything else seems to work fine but even though the last thing I do in the "ok" case is .set_checked(false) the box remains checked. Here is the javascript:

            function checkbox1_ClientClicked(sender, eventArgs) {
                var checkbox1 = $find('<%=checkbox1.ClientID%>');
                function CallbackFn(arg) {
                    if (arg) {
                        var checkbox1 = $find('<%=checkbox1.ClientID%>');  // I know I probably don't need this, just being safe
                        var checkbox2 = $find('<%=checkbox2.ClientID%>');
                        checkbox1.set_checked(true);
                        checkbox2.set_checked(false);
                    }
                    else {
                        checkbox1.set_checked(false);
                    }
                }
                if (checkbox1.get_checked()) {
                    return radconfirm("warning text", CallbackFn, 330, 150, null, "title");
                }
            }

I've also tried the ClientCheckedChanged and ClientCheckedChanging events with similar results. What obvious, basic thing am I missing? 8^)

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Jun 2014, 05:28 AM
Hi Harry,

Please try the below JavaScript to check the CheckBox based on RadConfirm.

JavaScript:
function checkbox1_ClientClicked(sender, args) {
    sender.set_checked(false);
    var confirm = radconfirm("Are you Sure?", callBackFn, 300, 200, null, "Confirm", null);
}
function callBackFn(arg) {
    var checkbox = $find("<%=radbtnTestingCheckbox.ClientID%>");
    checkbox.set_checked(arg);
}

Thanks,
Shinu.
0
Harry
Top achievements
Rank 1
answered on 12 Jun 2014, 12:38 PM
That worked! The main difference seems to be using 'sender' rather than the object returned from $find, though I would have thought they pointed to the same object. Still new to JS so there's probably a nuance I'm missing. Many thanks!
Tags
General Discussions
Asked by
Harry
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Harry
Top achievements
Rank 1
Share this question
or