justinmind-logo
 
Upvote 1

"on change" event for programatic changes?

Answered Victor Conesa 8 years ago

Hello,


When setting the text (value) of an input field via an interaction (e.g., a button press) the "on change" event of that input field does not get fired—why?


Thanks,


Dominik

Replies (4)
photo
1

Hi Dominik,


this event has been programmed to work in this way. May I ask you what you were trying to do?


Best,


Sonia Durán

photo
1

Hi Sonia,


Thanks for your reply!


Here is an example to illustrate why I believe the "on change" event should be fired on any value change—be it triggered by the user directly or programmatically:


I have an input field to which I attached several events with multiple actions each. For example, I want the input field to display "Search" if it is empty, and I also want it to move to the center of the screen if it is empty.


I also have an erase-all button which—when clicked—empties the input field.


Now, I want the input field to behave exactly the same when it is emptied—no matter if the user deletes its content by using the keyboard or by clicking my erase-all button.


Naturally, I want to avoid duplicate logic, that is, I want to define the input field's behavior on content change only once. This would be taken care of by the "on change" event firing also on programmatic value changes.


What is more, the name "on change" suggests that something happens on change. It does not contain any information that would suggest that only changes by a user trigger the event.


Thanks,


Dominik

photo
1

Hi Dominik,


It makes sense what you are describing. This information has been forwarded to our development team in order to evaluate if this could be changed on future updates.


Best,


Sonia Durán

photo
1

Hi Sonia,


Thanks for your help! Looking forward to updates!


Best,


Dominik

Leave a Comment
 
Attach a file