我有一個默認情況下隱藏的窗體。這是CSS(筆):Chrome中最奇怪的錯誤,與重繪有關嗎?
span.error
display: none
position: relative
padding: .25em .5em
width: 75%
margin-top: 5px
margin-bottom: 15px
float: right
text-align: center
background: myorange
border-radius: radius
&:after
arrow(6px)
top: -12px
left: 50%
margin-left: -12px
border-bottom-color: myorange
然後在jQuery的我要顯示在AJAX回調的錯誤,所以:
$form.submit(function(e) {
e.preventDefault();
$.post($form.attr('action'), $form.serialize(), function(data) {
// handle ajax then show errors
$('.error').show(); // doesn't work properly here, only 2 show up
});
});
我遇到的問題是很奇怪的。我有6個錯誤,但只有2個出現在Chrome中。我嘗試過的每一個瀏覽器都能正常工作如果我打開和關閉devtools或放大和縮小一秒鐘,那麼錯誤就會按預期顯示。
我發現,如果我走了$('.errors').show()
外的submit
事件那麼它將按預期工作和所有6個錯誤出現。
$('.error').show(); //works here
$form.submit(function(e) {
e.preventDefault();
...
});
我還發現,如果我刪除float:right
那麼一切都在Chrome中工作正常,但我顯然需要這個屬性。我試圖用somesolutions I found觸發重繪,但目前還沒有運氣。被困了幾個小時...有關如何解決這個問題的任何想法?