这两天要解决extjs 控件 Ext.form.field.Text mastarget:"qtip" 无法显示后台传来的错误
傻逼了一天,最终发现问题所在:调用了 setActiveErrors([ret.data.ErrorMsg]);是将错误信息加入到布局里面
但此时是ajax内加入的无法刷新显示,所以必须调用updateLayout();重新更改布局,才能将qtip错误信息显示出来
(看来在ajax中改变容器内容,是updateLayout()是必不可少的!)以前没关注这个方法,原来如此重要!shit!
找了良久最关键的原因还是没有 配置 Text的activeErrorsTpl
,如果没有配置的话,会自动引用一个“list-box”之类的样式,会把传来的信息给display:"hidden" 隐藏掉,oh!so bad!
.所以配置activeErrorsTpl 给予一个样式类show(
.show{ auto;
height: auto;
margin: 0 1px;
color: indianred;
background-image: url(images/form/exclamation.gif);
background-repeat: no-repeat;
list-style: none;
})
我们看看 masTarget 几种赋值对text造成的影响:(源自extjs api中)
If `labelAlign: 'left', `msgTarget: 'side'`
*
* +----------------------+----------------------+-------------+
* | Label: | InputField | sideErrorEl |
* +----------------------+----------------------+-------------+
*
* If `labelAlign: 'left', `msgTarget: 'under'`
*
* +----------------------+------------------------------------+
* | Label: | InputField (colspan=2) |
* | | underErrorEl |
* +----------------------+------------------------------------+
*
* If `labelAlign: 'top', `msgTarget: 'side'`
*
* +---------------------------------------------+-------------+
* | label | |
* | InputField | sideErrorEl |
* +---------------------------------------------+-------------+
*
* If `labelAlign: 'top', `msgTarget: 'under'`
*
* +-----------------------------------------------------------+
* | label |
* | InputField (colspan=2) |
* | underErrorEl |
* +-----------------------------------------------------------+