Skip to main content

Bug Tracker

Side navigation

#13787 closed bug (notabug)

Opened April 18, 2013 08:41AM UTC

Closed April 18, 2013 12:21PM UTC

Programmatically changing text prevents Change event from being triggered

Reported by: joaop.aires@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

I've came up with this very interesting "feature".

He's my story, step-by-step:

1) I have a TextBox where users enter data.

2) For some reason, I want that data not to exceed 5 characters.

3) To do so, I've implemented a function that, OnKeyUp ensures that by substringing the string whenever it exceeds the max limit.

4) I also need to do something on the Change event (and yes, I only want to do things after the user leaves the TextBox)

What I found out it that, if the function on 3) runs, the Change event will not occur. You can test this behavior here: http://jsfiddle.net/jpaires/dpujx/

Just enter "12345" and leave the TextBox. The console will show a "a-ok" messagem. However, if you enter "123456" the function on 3) will trim the message to "12345" but when you leave the Textbox no Change event seems to occur.

This doesn't sounds like the correct behaviour for the Change event. My interpretation is that the programmatic change to the TextBox is resetting some change "flag".

PS - I know there are other ways of doing this but my main question is why programmatically changing text prevents Change event from being triggered?

Attachments (0)
Change History (1)

Changed April 18, 2013 12:21PM UTC by scottgonzalez comment:1

resolution: → notabug
status: newclosed

That's just how the change event works. Try it without jQuery.