jquery - Sorting a rails created li by date -


i'm trying sort these li's date value rails generating. closest have gotten like:

<ul id="press-items-ul">     <% @press.each |press| %>         <li class="press-link-li">             <h2 class="press-source"> <%= link_to press.source, press.link %>  </h2>             <h2 class="press-title"> <%= link_to press.title, press.link %> </h2>             <h2 class="press-date"><%= press.date %> </h2>         </li>     <% end %> </ul> 

the closest have gotten below pulls out dates, puts in array , sorts them no effect on actual list item. don't need them sortable. sorted recent entry on top. points in right direction apprecatiated.

var elems = $.makearray($(".press-date")); elems.sort(function(a, b) {    return new date( $(a).text() ) < new date( $(b).text() ); }); $(".press-link-li").html(elems); 


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -