JQuery UI 对话框:密码输入导致冻结 [英] JQuery UI Dialog: Password inputs causing freezing

查看:27
本文介绍了JQuery UI 对话框:密码输入导致冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一种奇怪的行为,似乎只发生在 Chrome 和 JQuery UI 中.首先在密码字段中输入字符时,一切正常.但是,如果您尝试退格到输入中的最后一个字母,浏览器会锁定所有客户端操作.此外,如果您尝试突出显示输入的字符并退格,客户端操作会冻结.

This is a odd behavior that seems to only happen in Chrome and with JQuery UI. When entering characters into a password field at first everything functions correctly. However, if you attempt to backspace to the last letter in the input, the browser locks up all client side operations. Also, if you try and highlight the characters entered and backspace the client side operations freeze.

只是想看看是否有人遇到过同样的问题,以及他们是如何解决的.

Just reaching out to see if anyone has encountered this same issue, and how they resolved it.

为了解决这个问题,我们在 2 个以上的独特页面主页视图上自动打开对话框.这是一个列表页面,因此可以触发它,对于给您带来的不便,我深表歉意,但我无法删除计数器.

In order to experience the issue, we have the dialog auto opening on 2+ unique page home views. Here is a listings page so it can be triggered, I apologize for the inconvenience but I can't remove the counter.

页面:http://www.christineleeteam.com/area/eagleharbor

推荐答案

我们遇到了同样的问题,使用了 Benkod 的解决方案.我们对其进行了一些改进,以处理使用删除键(而不是退格键)删除密码文本的情况.另一种情况是选择控件中的所有文本并键入新文本以替换它.这是我们使用的脚本:

We encountered the same issue, and used Benkod's solution. We improved it a little to also handle cases where the password text is deleted with the delete key (and not backspace). Another case is when all the text in the control is selected and new text is typed to replace it. Here is the script we used:

    Sys.Application.add_load(function() {
        $('input[type=password]').keydown(function(event) {

            var isAllTextSelected = this.value.slice(this.selectionStart, this.selectionEnd) == this.value;
            var isLastChar = $(this).val().length == 1;
            if (isAllTextSelected && $(this).val().length > 0) {
                $(this).val('');
            }
            if ((event.which == 8 || event.which == 46) && (isLastChar || isAllTextSelected)) { //backspace event

                event.preventDefault();
                $(this).val('');
            }
        });
    });

这篇关于JQuery UI 对话框:密码输入导致冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆