Skip to main content

Bug Tracker

Side navigation

#12029 closed bug (invalid)

Opened July 06, 2012 03:20AM UTC

Closed July 06, 2012 04:48AM UTC

on() not the same as live() for keypress event

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

The documentation states on() should be used in place of live for jquery 1.7.

For newly added elements, the 'click' event is working as of 1.7.2 (was broken in previous versions), but 'keypress' does not work with on() (works with live()).

$("input").live( 'keypress', function(event) {
	if ( event.which == 13 ) {
		event.preventDefault();
		alert("works");
	}
});
$("input").on( 'keypress', function(event) {
	if ( event.which == 13 ) {
		event.preventDefault();
		alert("doesn't work");
	}
});
Attachments (0)
Change History (1)

Changed July 06, 2012 04:48AM UTC by mikesherov comment:1

resolution: → invalid
status: newclosed

Please ask for help on the forums; You're using .on incorrectly.