简体   繁体   English

Ext-JS Quicktip图标CSS问题

[英]Ext-JS Quicktip Icon CSS Question

I've created a custom vtype to verify my emails, my TO field uses an exclamation.jpg icon, but I want my CC and BCC fields to use a warning icon (since its not req). 我创建了一个自定义vtype来验证电子邮件,“收件人”字段使用exclamation.jpg图标,但是我希望“抄送”和“密件抄送”字段使用警告图标(因为它不是必填项)。 I've been trying to wrap my head around navigating Ext-JS's API to determine what attributes I had access to (do I have access to attributes that the VType extends from?), and where I needed to specify this. 我一直在努力探索Ext-JS的API,以确定我可以访问哪些属性(我是否可以访问VType扩展的属性?),以及需要在何处指定它。

I see through firebug the invalid message uses the css class .x-form-invalid-msg, how could I tell it to look at a different CSS class (looking at firebug I don't know what ID to reference)? 我通过萤火虫看到无效消息使用css类.x-form-invalid-msg,如何告诉它查看其他CSS类(看着萤火虫,我不知道要引用哪个ID)? Could I utilize the cls: attribute? 我可以利用cls:属性吗? Or Could I utilize an Ext.get and tweak the cls attribute? 还是可以利用Ext.get并调整cls属性?

EDIT** 编辑**

I just found the invalidClass Attribute... but I can't seem to get it working. 我刚刚发现了invalidClass Attribute ...但似乎无法正常工作。 Investigating... 正在调查...

EDIT** 编辑**

So it looks like adding the invalidClass attribute to the CC Textbox causes the CC class to reflect the change, but the VType Error isn't changing. 因此,似乎将invalidClass属性添加到CC文本框会导致CC类反映更改,但VType错误不会更改。


Code for my vType Below (does vType have a cls: it can use?): 我的vType的代码如下(vType是否具有cls:可以使用?):

 Ext.apply( Ext.form.VTypes, { anEmail: function(emailString) { var temp = new Array(); temp = emailString.split(","); for (var i = 0; i<temp.length; i++) { if (!/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/.test(Ext.util.Format.trim(temp[i]))) { return false; } } return true; } , anEmailText: 'An Email is Required, separated by commas.' } ); 


EDIT** Hey I figured it out after looking @Jollymorphic explanation. 编辑**嘿,我在查看@Jollymorphic解释后才知道。 My CSS had the extra problem that these textboxes were in form elements. 我的CSS的另一个问题是这些文本框位于表单元素中。 I applied the CSS rule to the ID's of the fields that contained the x-form-invalid class. 我将CSS规则应用于包含x-form-invalid类的字段的ID。 So it looks similar to this. 所以看起来与此类似。

 #x-form-el-bcc .x-form-invalid-msg{ color: #4279b5; font: normal 11px tahoma, arial, helvetica, sans-serif; background-image: url(../images/iwe/shared/warning.gif); } #x-form-el-cc .x-form-invalid-msg{ color: #4279b5; font: normal 11px tahoma, arial, helvetica, sans-serif; background-image: url(../images/iwe/shared/warning.gif); } 

You could use the cls configuration property to attach a custom CSS class to each of the components whose invalid icons you want to change, and then add a rule to your CSS stylesheet along these lines: 您可以使用cls配置属性将自定义CSS类附加到要更改其无效图标的每个组件 ,然后按照以下几行规则在CSS样式表中添加一条规则:

.your-special-class .x-form-invalid-msg
{
   background-image: url("../my-images/my-warning.gif");
}

The textfields would look like this: 这些文本字段如下所示:

items: [{
  // ...
  vtype: "yourVType",
  cls: "your-special-class",
  // ...
}, {
  // ...
  vtype: "yourVType",
  cls: "your-special-class",
  // ...
}, {
  // Some other textfield with no special vtype or cls properties.
}]

The end result is this: 最终结果是这样的:

  • Each of your special text fields includes "your-special-class" in the class attribute of the DIV that contains both the textfield and its (normally hidden) invalid contents message. 您的每个特殊文本字段在DIVclass属性中都包含“您的特殊类”,该属性同时包含文本字段及其(通常是隐藏的)无效内容消息。
  • When the invalid message is shown, the CSS selector above applies to it more specifically than the simple .x-form-invalid-msg selector in Ext's CSS stylesheet because it specifies both the class of the invalid message element itself as well as the class of the DIV that contains it. 当显示无效消息时,上面的CSS选择器比Ext的CSS样式表中的简单.x-form-invalid-msg选择器更具体地适用于它,因为它既指定了无效消息元素本身的类,也指定了无效消息元素的类。包含它的DIV
  • Being more specific, the background-image attribute specified in your CSS rule overrides its counterpart in the Ext stylesheet, so that your background image is now used instead of the one from the Ext default theme. 更具体地说,在CSS规则中指定的background-image属性会覆盖Ext样式表中的对应属性,因此现在使用的是背景图像,而不是Ext默认主题中的背景图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM