Ng-blur does not fire event on firefox with input number

I am trying to use ng-blur with an html input element (type = number) in firefox .

The problem I discovered is that when using the up and down arrows of the input number, neither blurring nor focal events are fired using firefox, while chrome works fine.

You can reproduce the problem at http://jsfiddle.net/chonw54e/

<div ng-app ng-init="focus=false;blur=false;active=false">
    <input type="number" ng-class="{ myFocus: focus, myBlur: blur }"    ng-focus="focus=true;blur=false;" ng-blur="blur=true;focus=false;">
    <p>focus: {{focus}}</p>
    <p>blur: {{blur}} </p>
</div>

Just load the page (using both firefox and chrome) and press the up / down arrows to enter the html number

input number

What am I doing wrong?

Thanks for the help!

EDIT: 12/11/2015

Decision

@ Arg0n fixes the problem. However, this seems to be a problem with either firefox or angularjs.

angular github

angular. firefox, (, , ).

EDIT: 14/12/2015

Firefox, bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1232233

+4
1

jQuery, . this :

JavaScript

$(function(){
  $("input[type='number']").on("click", function(){
    $(this).focus();
  });
});

jQuery . this:

JavaScript

document.onreadystatechange = function() {
  if (document.readyState == "complete") {
    var inputs = document.querySelectorAll('[type="number"]');
    for (var i = 0; i < inputs.length; i++) {
      inputs[i].onclick = function() {
        this.focus();
      }
    }
  }
}

input, . (input type number).

+2

Source: https://habr.com/ru/post/1619182/


All Articles