jQWidgets Forums

jQuery UI Widgets Forums Editors Button, RepeatButton, ToggleButton, LinkButton jqxCheckBox: Getting the value on click

This topic contains 2 replies, has 2 voices, and was last updated by  Jazz 11 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • jqxCheckBox: Getting the value on click #32359

    Jazz
    Participant

    I’m hoping this is just something silly that I’m doing or something I’m just not aware of. But, how do I get the current value from a jqxCheckBox widget when it’s being clicked?

    Doing the following doesn’t work as expected:

    $('myCheckbox').jqxCheckBox();
    $('myCheckbox').on('click', function(event) {
    var mybool = $(this).val();
    });

    The value of mybool will always be the opposite of what it should be. So, clicking the checkbox to tick it, this value is false. But it is only false during the click event. After that calls to val() return true as expected. I’m assuming this is because the internal value is changed until after the click event is fired.

    a) Is there some other way to get the value during the click event?
    or
    b) is it safe to just invert the value? This isn’t exactly ‘tidy’, but could be a valid work around.

    I guess, how are others getting the value of a checkbox from inside a click event?

    jqxCheckBox: Getting the value on click #32363

    Peter Stoev
    Keymaster

    Hi Jazz,

    For using jqxCheckbox, please look at the events that is supports in its API documentation. From it, you will learn how to get the current value and how to trigger the changes of the sate.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    jqxCheckBox: Getting the value on click #32672

    Jazz
    Participant

    Ah, of course. I should use the ‘change’ event. I just got a little lost in the demo documentation and didn’t see that. Thanks Peter.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.