jquery - IE 11 Locks up with on input -
ie seems lock code, , can't figure out why. works fine in ff , chrome:
<input type="text" class="form-control" placeholder="username search" name="uname" id="uname" value=""> script:
$('#uname').on('input', function() { $.get('?go=more_users&searchby=username&searchterm='+encodeuricomponent($('#uname').val()),function (result) { $('#main-block').html(result); $('#uname').focus(); tmpstr = $('#uname').val(); $('#uname').val(''); $('#uname').val(tmpstr); } ); }); once put mouse in input box, locks right up. see no errors or messages in console , server log shows nothing.
any ideas?
since moving keydown seems clear locking problem, adding settimeout should fix cross-browser issues , make page more efficient (it should reduce number of ajax requests sent.)
$('#uname').on('keydown', function () { var $this = $(this); cleartimeout($this.data("timer")); $this.data("timer",settimeout(function(){ $.get('?go=more_users&searchby=username&searchterm=' + encodeuricomponent($this.val()), function (result) { $('#main-block').html(result); $this.focus(); // purpose of next 3 lines??? tmpstr = $this.val(); $this.val(''); $this.val(tmpstr); }); },250)); }); this cause ajax request sent if user stops typing 250ms. user hardly notice delay.
Comments
Post a Comment