如何在Ext.form.TextField中显示/隐藏密码 [英] How to show/hide password in Ext.form.TextField

查看:453
本文介绍了如何在Ext.form.TextField中显示/隐藏密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你可以告诉我解决方案,使点击另一个按钮的密码字段的输入文本显示/隐藏?我已经尝试更改该文本字段的inputType属性,但是在那时渲染,因此它不会影响。另外一种方式是创建2个文本框和粘贴/隐形他们,但我不喜欢这样做,因为它看起来像欺骗...
提前感谢。

解决方案

这个帖子有点老了,但我以为我会回答。也许它会帮助别人。



你是正确的,在项目呈现之后,它的类型已被设置为DOM中的密码。因此,我们需要直接操纵DOM。让我们说我的窗口有1个项目,一个FormPanel,我在这个FormPanel中有一个项目,一个文本框。我最初在我的配置选项中设置了inpupType:'password'。现在我想改变一下这是我会做的:



this.get(0).getForm()。get(1).getEl()。dom.type ='text' / p>

(我假设这是一个事件处理程序,具有我的窗口的范围)



DOM并立即显示我的密码作为文本。要更改它:



this.getForm()。get(1).getEl()。dom.type ='password'



在现实世界的情况下,我不会使用get(index),但是要为文本框设置一个名称并使用find,或者我将创建一个指向textfield的var。



希望这有助于某人。



Ricky


could you please show me the solution to make the input text of password field show/hide when clicking another button?! I've tried to change the inputType property of that textfield, but it was rendered at that time so it didn't affect. Another way is create 2 textfields and visbile/invisible them, but I don't like do this, because it looks like cheating... Thank in advance.

解决方案

Well this post is a little old, but I thought I'd answer it anyway. Maybe it will help someone else.

You are correct that after the item is rendered it's type has been set to 'password' in the DOM. Thus we need to directly manipuate the DOM. Let's say I window that has 1 item, a FormPanel, and I have 1 item in this FormPanel, a textfield. I initially set it's inpupType: 'password' in my config options. Now I want to change that. Here is what I would do:

this.get(0).getForm().get(1).getEl().dom.type = 'text'

(I assume that this is in an event handler that has the scope of my window)

That will change the DOM and immediately show my password as text. To change it back:

this.getForm().get(1).getEl().dom.type = 'password'

In a real world situation I would not use get(index), but either set a name for the textfield and use find, or I would create a var that points to the textfield.

Hope this helps someone.

Ricky

这篇关于如何在Ext.form.TextField中显示/隐藏密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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