简体   繁体   中英

Why don't I get focusout() event, when an input field looses focus (using scrollbar)

I'm trying to put an input field into a scrollbar using iscroll5 . I need to listen to the input's focusout() event but I never get notified when clicking anywhere else. It works when I remove the scrollbar!

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">

<title>iScroll demo: simple</title>

<script type="text/javascript" src="iscroll5.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">

var myScroll;

function loaded () {
    myScroll = new IScroll('#wrapper', { mouseWheel: true });

   $("input").focusout(function(e) {
      console.log("input lost focus"); // NEVER GET HERE
   });

   $("input").click(function(e)  {
      console.log("input onClick");
   });
}

</script>
</head>
<body onload="loaded()">
<div id="header">iScroll</div>

<div id="wrapper">
    <div id="scroller">
    <ul>
        <li>Pretty row 1</li>
        <li>Pretty row 2</li>
        <li>Pretty row 3</li>
        <li>Pretty row 4</li>
        <li><input type='text'></li>
        <li>Pretty row 6</li>
              ...............
    </ul>
    </div>
</div>

 <div id="footer"></div>

</body>
</html>

尝试在选项中添加“ preventDefault:false”,我已经完成了,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM