jQuery UI Widgets Forums Editors CheckBox, RadioButton Checkbox change event

Tagged: ,

This topic contains 4 replies, has 3 voices, and was last updated by  aleidenfrost 1 year, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Checkbox change event #102025

    aleidenfrost
    Participant

    Hi there,
    I have encountered a problem with the checkbox change event.

    The scenario: I have a checkbox and several other input elements, mostly text inputs. There is an event handler on the checkbox change event.

    The problem: If a user inputs something in a text input or an editable grid and then immediately checks a checkbox, the previously used input only loses focus AFTER the check event has run. This is a problem, because in the check event I want to manipulate an object, whose properties are bound to the input elements. But before the input element loses focus, the last input is not yet realized in the object, leading to data states in the object that the user does not expect.
    I expect the prior element to lose focus before any event of the new element is fired. The present order of events does not make sense.

    As a workaround, I use $(":focus").blur() in the change event handler before doing anything else. This works, but it would really help if I could rely on events firing in the locigal order.

    Thanks for your attention,
    Anne

    Checkbox change event #102043

    Hristo
    Participant

    Hello Anne,

    Could you clarify your issue?
    You use jqxCheckBox in jqxGrid. Is this right?
    Could you provide us with a simplified example that demonstrates this issue?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Checkbox change event #102140

    aleidenfrost
    Participant

    Hi Hristo,

    please see this JSFiddle for a simplified example. Write something in the textbox, then immediately check the checkbox without clicking anywhere else first. You will see that the checkbox change event is called before the text input change event.
    This is contrary to the expected sequence of events. As I said in my original comment, this can be problematic, if you want to do additinal data processing in the check change event.
    The workaround I described works of course, but if you encounter this problem for the first time, it takes a while to even find the cause.

    Anne

    Checkbox change event #102145

    Peter Stoev
    Keymaster

    Hi Anne,

    The described behavior is actually by design. Text Inputs change events as in the standard HTML Input is raised on blur.

    Regards,
    Peter

    Checkbox change event #102168

    aleidenfrost
    Participant

    Hi Peter,

    I’m aware that the text input change event is raised on blur and that this is the correct behaviour.
    I just think that the text input should be blurred (and thus raise the change event) before the check change event is raised. The way it works now seems to be: click on checkbox > check change event > checkbox gets focus > text input blur > text input change event. In my opinion it should be: click on checkbox > checkbox gets focus > text input blur > text change event > checkbox change event.

    Please consider that if I use a button, the order of events is exactly as I expect: when clicking a button, the text input loses focus (raising its change event) before the button’s click event is raised. I don’t see why it has to work differently for a checkbox.

    Regards,
    Anne

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

You must be logged in to reply to this topic.