4

The rest of the browsers it is working fine

Whenever I type a number, I'm getting the keyup event in all mobile and computer browsers except Safari, the problem is keyup/keydown event is not firing in Safari.

I tried with all possible bind &trigger events. I am looking to change the value based on the user input rather than increasing the count through + or - buttons

var gotlist = [];

$('.count-val').trigger('keyup', function(e) {
  debugger;
  //console.log(" keyup triggered");

  if (e.keyCode === 13) $(this).trigger('input');
}).on('input', function(e) {
  var countid = $(this).attr("id");
  //console.log(e.keyCode + " keyup triggered");
  var val = Number($(this).val());
  if (val <= 0 || isNaN(val)) {
    for (var i = 0; i < gotlist.length; i++) {
      if (gotlist[i].id == countid) {
        gotlist.splice(i, 1);
        $("#disp_" + countid).remove();
      }
    }
    $(this).val("");

  } else {

    for (var i = 0; i < gotlist.length; i++) {
      if (gotlist[i].id == countid) {
        gotlist[i].count = val;
      }
    }
  }
  maindisp();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<li class="list-item">
  <div class="dispcount">
    <i class="fa fa-minus-circle" onclick="reducecount({'id':'item_2','area':'8','count':'1'});></i>
    <span><input type=" number " class="count-val " inputmode="numeric " pattern="[0-9]* " title="Non-negative integral number " id="item_4 " value=" "></span>
    <i class="fa fa-plus-circle addcount " aria-hidden="true " onclick="addvalues({'id':'item_2','area':'8','count':'0'}); "></i>
    </div>
    Bed
 </li>
Mano CC
  • 41
  • 3
  • Please update the snippet I made for you with relevant jQuery, HTML and CSS. Your onclick in not valid. You are missing a `})"` – mplungjan Oct 05 '18 at 07:04
  • We are missing functions reducecount, addvalues, maindisp and the var gotlist Also you have TWO mistakes in `{'id':'item_4','count':'1'}` – mplungjan Oct 05 '18 at 07:47

2 Answers2

2
$("#search").on('input propertychange',function(){
  //do something
}

I guess you have problem with IOS, "keyup" event is not support by original IOS. You may bind js event "input" and "propertychange" for listening.

Yang Daniel
  • 125
  • 5
-2

press manuallt aon the keyboard, it will work !

  • 1
    Welcome to SO. Please take more care to write a proper answer. For example us ea spell checker and proper punctuation – mplungjan Oct 05 '18 at 07:20