JQuery 自动完成不调用移动设备键盘后退的更改方法

贾耶什·奈

我正在网站中实现 Jquery 自动完成功能,它的问题是如果我们在 Android 设备中按住后退按钮,则不会触发文本更改事件

 $("#user_name4").autocomplete({

    source: function( request, response ) {
      if (user_id_4 != 0 ) {
        user_id_4 = 0;
        my_entry_fees = my_entry_fees - entry_fees;
        document.getElementById("join_btn").value= "Pay "+my_entry_fees+" Rs;";
        my_joined--;
      }
      $.ajax({
        url: "../API/v1/SearchUser",
        data: 'value='+request.term,            
        dataType: "json",
        headers:
        {
          'Authorization':'Basic dGVzdDp0ZXN0',
          'Authorizations': tokensdb,
        },
        type: "POST",
        success: function (data) {
         response(data.data);
       }
     }); 
    },
    minLength: 1,
    select: function(event, ui) {

     user_id_4=ui.item.user_id;
     var username=ui.item.username;
     $('#user_name4').val(username);
     my_entry_fees = my_entry_fees + entry_fees;
     document.getElementById("join_btn").value= "Pay "+my_entry_fees+" Rs";      
     my_joined++;    

   },
   html: true, 
   open: function(event, ui) {
    $(".ui-autocomplete").css("z-index", 1000);

  }
})
  .autocomplete( "instance" )._renderItem = function( ul, item ) {

    var path = "http://graph.facebook.com/"+item.facebook_id+"/picture?type=square";
    return $( "<li><div><img alt= '' src='"+path+"'><span>"+item.username+"<br>"+item.label+"</span></div></li>" ).appendTo( ul );
  };

});

这是我用于自动完成的代码

贾耶什·奈

我找到了解决方案:

$("#user_name4").keyup(function() {
  if (!this.value) {
    if (user_id_1 != 0 ) {
      user_id_1 = 0;
      my_entry_fees = my_entry_fees - entry_fees;
      document.getElementById("join_btn").value= "Pay "+my_entry_fees+" Rs";
      my_joined--;
    }
  }
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章