I am new to jQuery and I want to apply a fade in effect to an item being created in my rails application. The object appends to the DOM but the fade effect doesn't seem to work! This seems like it should be a fairly easy solution but I think the rails instance variable is throwing things off. I have tried wrapping my create javascript in a document ready function but that didn't seem to help either. Thank you in advance!
index.html.erb
<div class="row">
<div class="col-lg-12">
<% @events.each do |event| %>
<%= render event %>
<% end %>
</div>
</div>
create.js.erb
$('#new_event').remove();
$('#new_event_link').show();
$('#events').append('<%= j render(@event) %>').fadeIn(5000);
_events.html.erb
<ul id="events">
<li>
<h4><%= event.location %></h4>
<p><%= event.description %></p>
</li>
</ul>
For others, below is the working code
index.html.erb
<div class="row">
<div class="col-lg-12">
<ul class="events">
<% @events.each do |event| %>
<%= render event %>
<% end %>
</ul>
</div>
</div>
create.js.erb
$('#new_event').remove();
$('#new_event_link').show();
$('#events').append($('<%= j render(@event) %>').hide().fadeIn(5000));
_events.html.erb
<li>
<h4><%= event.location %></h4>
<p><%= event.description %></p>
</li>