0

using latest Chrome browser.

even after wiring up the onchange event for an inputsurface the dirty way since there is no extended event to just do inputsurface.on('change',function(){}):

MyInputSurface.prototype.deploy = function deploy(target) { this._superDeploy(target);

    target.onchange = function() {
        console.log('test change');
    };
    target.onclick = function() {
        console.log('test click');
    };
};

The onchange event does not get fired until i click back in the browser window. The click event works just fine. Any advice?

1 Answers1

0

The onchange event does not fire until the input loses focus. This is why you have to click in the browser window again before your callback is run.

From the IE Dev Center:

This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by onblur when the control is also losing the focus.

If you want the value of the input as the user is typing, you'll have to listen for the input's input event.

Again from IE Dev Center:

You can use the oninput to detect when the contents of a textArea, input type=text, or input type=password have changed. This event occurs immediately after modification, unlike the onchange event, which occurs when the element loses focus.

When your input callback fires, simply take the target value as you would with change.

Clay Smith
  • 56
  • 5