当消息框"悬停"时,我有这个代码可以显示工具提示.所有消息框都在一个名为chatbox的div中.
$('.box').hover(function(){
var htmltooltip = '<div id="info" class="shadow">';
htmltooltip += '<h4>Label info</h4>';
htmltooltip += '<img src="images/defaultphoto.gif"/>';
htmltooltip += '</div>';
$(this).append(htmltooltip).children('#info').hide().fadeIn(400).css('left', -150);
}, function() {
$('#info').remove();
}
);
Run Code Online (Sandbox Code Playgroud)
这是我的名为#info的聊天框,框和工具提示的css代码
#chatbox {
position: absolute;
overflow-y:auto;
top:40%;
left:50%;
background:#fff;
height:80%;
width:550px;
border:3px solid black;
}
.box{
width:90%;
height:auto;
margin:5px 20px 0px 0px;
border:3px solid #918750;
float:left;
cursor: pointer;
}
#info{
position:absolute;
display:block;
background:#7F7777;
width:300px;
padding-bottom: 0.5em;
z-index:25;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当通过聊天框的限制时,聊天框div会切断工具提示.这是一个jsfiddle:http://jsfiddle.net/Ifalcao/k9Yrc/2/
聊天框div中的溢出规则必须存在,否则如果我有许多消息框,它们将通过聊天框的限制.(http://jsfiddle.net/Ifalcao/URBDE)我需要聊天框内的消息框,但是聊天框外面的消息框的工具提示.
提前致谢.
我创建了一个名为 Term 的模型和一个验证器,如下所示:
from django.db import models
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
def validate_insensitive_exist(value):
exists = Term.objects.filter(word__iexact = value.lower()).exists()
if exists == True:
raise ValidationError("This term already exist.")
class Term(models.Model):
word = models.CharField(max_length=200, unique=True, validators=[validate_insensitive_exist])
related_term = models.ManyToManyField("self", null=True, blank=True)
def __unicode__(self):
return self.word
def natural_key(self):
return self.word
Run Code Online (Sandbox Code Playgroud)
这个验证器的作用是在我尝试添加一个已经存在的术语(小写或大写)时引发异常,并且它工作正常。我的问题是,当我尝试编辑现有术语时(只是将字符大写或小写 - 但单词是相同的),会引发异常,因为实际上我正在尝试添加一个已经存在的单词,成为自己。我想要的是验证我输入的新词与所有其他术语的对比,忽略最初出现并且我实际上正在更改的词。
任何人都可以帮助我吗?