timepicker icon indicating copy to clipboard operation
timepicker copied to clipboard

change fires twice .. once on enter, and again on blur()

Open designosis opened this issue 8 years ago • 1 comments

See fiddle here.

The js is simply ...

	$('#time').timepicker({
		timeFormat: 'h:mm p',
		dropdown: false,
		change: function(){
			$('#result').append('<div>change</div>');
			// $(this).blur();
		}
	});

... and the behavior I want is ...

  1. Click into the field.
  2. Type a number, and hit enter.

At this point, I'd like the input to lose focus. But since it doesn't, I click or tab away, only to have change fired once again. Change fires a second time when the input loses focus. That ain't right. And if I uncomment the blur() line, it also fires twice.

Obviously I could add a var already_changed = 0 global variable, but that's just messy. Any tips on accomplishing my goal here?

designosis avatar Feb 19 '17 13:02 designosis

The change event is also fired at init, which is also not right....

princeofnaxos avatar Jul 09 '17 16:07 princeofnaxos