は、私はすべてのレールの形に似ているレールフォームを持っているし、何が失敗した場合、標準のレールのエラーが表示されます。レール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がある私に言っているが、1つ私はRailsがそのロードされた後のページに、このdiv要素をロードしている推測しているがあります。
これに対処する方法はありますか?ページには#errorExplanation
が本当にない場合は#spinner
しか表示されませんか?
クリックイベントが発生していると思われます。要素が存在する場合 – Shad