나는 모든 레일 형태와 같은 인 레일 형태가 무엇이든이 실패 할 경우 표준 레일 오류가 나타납니다rails errorExplanation이 내 jquery와 충돌합니까?
<div id="errorExplanation" class="errorExplanation">
<h2>2 errors prohibited this account from being saved</h2>
<p>There were problems with the following fields:</p>
<ul><li>First Name can't be blank</li>
<li>Number is not a valid credit card number</li></ul>
</div>
하지만이 클릭 제출하면 스피너를 팝업 할 필요가 페이지에 몇 가지 jQuery를 가지고 :
$(document).ready(function(){
$('#add_account').click(function(){
console.log($('#errorExplanation').length);
$('#spinner').show();
});
});
그러나 console.log
은 항상 0이고 나는 페이지에는 #errorExplanation
이없는 경우에만 표시 스피너가 필요합니다.
console.log
에는 0이 있지만 하나가 있으므로 레일스가로드 된 후 페이지에서이 div를로드하고있는 것으로 추측합니다.
이 문제를 해결하고 페이지에 실제로 #errorExplanation
이없는 경우에만 #spinner
을 표시하는 방법은 무엇입니까?
나는 click 이벤트가 _before_ rails 'form validator를 발생시키고 있다고 생각합니다. – Shad