SE-AutoReviewComments icon indicating copy to clipboard operation
SE-AutoReviewComments copied to clipboard

Trigger "input" event upon insertion of text

Open codygray opened this issue 4 years ago • 0 comments

Changing the .val() property programmatically does not trigger either the "input" or "change" events (see references below). Both of these require actual user engagement. Normally, that behavior may make sense, but I have a userscript that hooks into this event to automatically resize the textarea control to accommodate its entire contents. This script is not compatible with AutoReviewComments unless AutoReviewComments triggers one of these events.

Therefore, this change triggers an "input" event whenever the Markdown is added to the targetObject (i.e., the textarea).

References:

  • https://stackoverflow.com/questions/37686861/input-event-not-working-if-value-is-changed-with-jquery-val-or-javascript
  • https://stackoverflow.com/questions/2247386/jquery-textbox-valxxxx-not-causing-change-to-fire
  • https://stackoverflow.com/questions/3179385/val-doesnt-trigger-change-in-jquery

codygray avatar Aug 01 '20 05:08 codygray