Bug Tracker

Opened 11 years ago

Last modified 10 years ago

#9121 closed feature

Add support for the HTML5 `oninput` event — at Version 17

Reported by: Andy E Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.6
Keywords: 1.7-discuss Cc:
Blocked by: Blocking:

Description (last modified by scottgonzalez)

All the edge major browsers appear to support the oninput event, which fires for text input into an element. The event itself is superior to key events because it fires for all forms of text input.

A while ago, I wrote a plugin that normalizes the event for browsers that don't support it, notably IE6-8. I believe this works well enough, despite a few limitations. Despite the existence of this event (and the plugin), every day I see people recommending the use of onkeyup for acting on user input. Integrating this event into jQuery may help these users learn to handle user input more appropriately.

The following fiddle demonstrates the event (and the plugin) very basically: All it does is copies the text as you type, but as you can tell, there is no visual delay.

Further reading:

All it does is copies the text as you type, but as you can tell, there is no visual delay.

Further reading:

Change History (17)

comment:1 Changed 11 years ago by dmethvin

Resolution: wontfix
Status: newclosed

This is quite a bit of code so I don't think we're in a hurry to include it into core. I'd suggest making it available as a plugin for now. If you'd like to suggest it for 1.7: https://spreadsheets.google.com/viewform?hl=en&authkey=CPmgicsO&formkey=dG0yTEs2ZTFWQUhDRUp5dzRyc3NwV2c6MA#gid=0

comment:2 Changed 11 years ago by john

Resolution: wontfix
Status: closedreopened

This was suggested for 1.7.

comment:3 Changed 11 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:4 Changed 11 years ago by jaubourg

Description: modified (diff)

-1, Let's start as a plugin so that we can assess the limitations.

comment:5 Changed 11 years ago by timmywil

-1, plugin

comment:6 Changed 11 years ago by timmywil

Component: unfiledevent
Description: modified (diff)
Priority: undecidedlow
Status: reopenedopen

comment:7 Changed 11 years ago by dmethvin

-1, Plugin first.

comment:8 Changed 11 years ago by anonymous

I wrote a plugin (as I said in the original filing). I also discuss some of the limitations in the same post.


Also, I've just noticed a bug in IE 9 where the oninput event doesn't fire when the backspace or delete keys are pressed - my plugin doesn't yet deal with that.

comment:9 Changed 11 years ago by john

Description: modified (diff)

-1, Would be good to prove as a plugin.

comment:10 Changed 11 years ago by Andy E

I'm not sure I understand this, do you mean an "official" plugin of some sort, or are people just not reading the ticket properly? Despite the ticket body and my other comment saying "I have already provided a plugin", everyone is still saying "-1 plugin first".

This has left me rather confused.

comment:11 Changed 11 years ago by Rick Waldron

Description: modified (diff)

hey Andy,

The comments you see are votes by core, bus and ui team members - this ticket was elevated to 1.7 proposal status.

As for official plugin, that's not likely - but if you write a solid plugin that has a high adoption rate, there is a better chance for core consideration, though rare

hope that cleared things up for you. Feel free to ask any other questions!

comment:12 Changed 11 years ago by ajpiano

Description: modified (diff)

+0, Seems the full ticket proposal got truncated and the fiddle and links got cut off - I've amended the description accordingly, and taken a look at your plugin. At the moment, it seems to have a number of shortcomings - the lack of support for delegation, for one, so it seems there's more research necessary into the problem. I like the idea of providing a cross-browser solution to this, however - have you heard of much adoption of the plugin thus far?

comment:13 Changed 11 years ago by [email protected]

I know several people have commented on my blog post and I regularly direct people to it from Stack Overflow. The plugin is the most visited page on my blog, but I only installed analytics a couple of weeks ago so there's not really enough data to say anything solid.

Telling people doesn't always work, though; there are a lot of confused individuals out there promoting events like keyup for input counters and the like. Most jQuery plugins detecting input use keydown, keypress or keyup too. input would serve them much better, catching cutting, pasting, dropping, spell checker corrections and others. IMO, having the event supported by jQuery would immediately increase awareness of the event, improving the quality of input detection scripts around the web.

As for delegation, it would work for the browsers that support the event natively, since it bubbles but, as for the older browsers (namely IE6-8), it would be difficult to get the event working for "future elements". I did think about this to some extent, though, and may be able to come up with a solution based on focusin or mouseover -- when an input element receives either event it is checked against the delegate selector and then the input event is applied to the element if necessary.

comment:14 Changed 11 years ago by Rick Waldron

Description: modified (diff)

Mathias also has an implementation: http://mathiasbynens.be/notes/oninput

I believe he is going to have this, with unit tests, on github today.

comment:15 Changed 11 years ago by Andy E

OK, so I managed to put together an experimental version of the plugin that supports delegate(). It only increased the size by a few lines.


I haven't added this to my blog post yet because I just realized I forgot to unset some data in the event teardown and I also need to implement a workaround for the bug in IE 9 where it doesn't fire oninput for backspace or delete. I've run out of time at the moment, though, so just posting what I've got so far.

comment:16 Changed 11 years ago by mathias

Note that my plugin is very barebones by design. I just wanted a simple, minimal solution that gracefully degrades in older browsers. jQuery, on the other hand, probably needs something more consistent across browsers.

Last edited 11 years ago by mathias (previous) (diff)

comment:17 Changed 11 years ago by scottgonzalez

Description: modified (diff)

-1, perhaps a good next step would be showing how this would improve some jQuery UI plugins

Note: See TracTickets for help on using tickets.