Topic: Display object with Jquery Newsticker Ruby on Rails

I have created a form for my news articles which I then call to my front page like so

<li class="clearfix">                       
<% @articles.each do |article| %>                       
<h4><a href="#"><%= article.header %></a></h4>                       
<p><%= article.created_at.strftime("%A %d %B %Y ")%></p>                       
<p><%= article.message %></p>                         
<a href="#" class="more">Read more</a>                       
<% end %>                       
</li>

But i want to use something a bit slicker and have come across Jquery Newsticker.

Now the view for this looks like this
  <ul id="js-news" class="js-hidden">     
  <li class="news-item"><a href="#">This is the 1st latest news item.</a></li>   
  <li class="news-item"><a href="#">This is the 2nd latest news item.</a></li>   
  <li class="news-item"><a href="#">This is the 3rd latest news item.</a></li>   
  <li class="news-item"><a href="#">This is the 4th latest news item.</a></li>
  </ul>

What i would like to be able to do is in the first li is call the most recent article created and in the second li call the next recent article and so on up until 4.

I have played around with it a little but all i seem to get is the text appearing at the end of the newsticker, not starting at the beginning

Any advice is appreciated

Re: Display object with Jquery Newsticker Ruby on Rails

I think your problem is that the li's contained under ul id="js-news"  don't have any unique identifiers,  all they have is the same class.   So if newsticker is asked to put something in an li element, it can't distinguish which of the four,  and it's just using the last one.

You'd probably have to add a different id to each one,  then figure out how to associate your data to the specific id.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Display object with Jquery Newsticker Ruby on Rails

HI Brad

Apologies for late reply, thank you for your answer, i actually got this to work in the end doing the following.

In my view

        <ul id="js-news" class="js-hidden">
        <li class="news-item" id="news-item1"<a href="#">
          <% @articles.each do |article| %>
          <li><%= article.message %></li>
        <% end %>
         </a></li></ul>

And in my controller

     @articles = Article.all(:order => "created_at DESC")

Last edited by richlewis14 (2012-04-06 08:10:27)