title: How to auto hide flash message when using ajax
body: <p>I use ujs to send ajax request and in my <strong>destroy.js.erb</strong> file i have the following code :</p>
  
  <pre><code>$("#wrapper").prepend('&lt;div class="flash-notice"&gt;&lt;%= escape_javascript(flash.discard(:notice)) %&gt;&lt;/div&gt;');
  </code></pre>
  
  <p>the line above show a flash-notice message when using ajax, what i want is to auto hide this flash message after a delay </p>
  
  <p>( <code>$(".flash-notice").delay(600).fadeOut(300);</code> ) doesn't work because the message is added dynamically and not existing in the DOM</p>