Permalink
Browse files

bind inputs to oninput event

  • Loading branch information...
1 parent aba9bb2 commit 0e9f956ed431070cb8350a566369ec898c90f184 bartes committed Nov 18, 2011
Showing with 6 additions and 1 deletion.
  1. +1 −1 src/widget/input.js
  2. +5 −0 test/widget/inputSpec.js
View
2 src/widget/input.js
@@ -817,7 +817,7 @@ angularWidget('input', function(inputElement){
inputElement.val(widget.$viewValue || '');
};
- inputElement.bind('keydown change', function(event){
+ inputElement.bind('keydown change input', function(event){
var key = event.keyCode;
if (/*command*/ key != 91 &&
/*modifiers*/ !(15 < key && key < 19) &&
View
5 test/widget/inputSpec.js
@@ -130,6 +130,11 @@ describe('widget: input', function() {
browserTrigger(element, 'change');
defer.flush();
expect(scope.name).toEqual('Kai');
+
+ element.val('Lunar');
+ browserTrigger(element, 'input');
+ defer.flush();
+ expect(scope.name).toEqual('Lunar');
});

1 comment on commit 0e9f956

@IgorMinar

good one!

After reading the spec I learned that the input event carries the updated value of the input field. so we don't need the $defer hack to get the new value.

That makes me wonder if we can just rely on this input event and remove the keyCode and $defer stuff. Does it work in all browsers that we support (ch, ff, o, s, ie8+)?

Please sign in to comment.