I create Simple deal site. When in index.html.erb loop working only first loop. But it work on show.html.erb
<h1>Listing Deal</h1><% @projs.each do |proj| %>
<%= proj.title %><br />
<% if Time.now < proj.end_date %>
<h3>Days Left:</h3> <div id="countdown" style="width:40%"> <%= distance_of_time_in_words(Time.now, proj.end_date) %> </div>
<% else %>
<h3> The Project period has passed! </h3>
<% end %>
<script type="text/javascript">
$(document).ready(function(){
$('#countdown').countdown({
"until" : new Date(<%= date_for_jquery_countdown(proj.end_date) %>)
});
})
</script><% end %>
Projs_helper.rb**
def date_for_jquery_countdown(date)
year = date.strftime('%Y')
month = date.strftime('%-m')
day = date.strftime('%d')
"#{year}, #{month}-1, #{day}"
end
application.js
//= require jquery.plugin
//= require jquery.countdown
My browser display index.html.erb only showing first is working, but others not display countdown
