:javascript $('.mark_all_read').live('click', function(){ $.ajax({ url: 'notifications/read_all', success: function(data, status, xhr) { $('.stream_element').removeClass('unread'); $("#notification_badge_number").addClass("hidden"); } }); }); $('.stream_element').live('click', function(evt){ var note = $(this).closest('.stream_element'), note_id = note.attr('data-guid'), nBadge = $("#notification_badge_number"); if(note.hasClass('unread') ){ note.removeClass('unread'); $.ajax({ url: 'notifications/' + note_id, type: 'PUT' }); } nBadge.html().replace(/\d+/, function(num){ num = parseInt(num); nBadge.html(parseInt(num)-1); if(num == 1) { nBadge.addClass("hidden"); } }); }); .span-1 = image_tag 'icons/mail_big.png', :height => 30, :width => 30, :style=>"margin-top:3px;" .span-10 %h2 = t('.notifications') .span-13.last.left .button.mark_all_read = link_to "Mark All as Read", "#" .span-24.last %ul.stream.notifications - @group_days.each do |day, notes| %li %h4= day %ul.notifications_for_day - notes.each do |note| .stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : ''}"} %span.from = link_to "#{note.actor.name.titleize}", person_path(note.actor) = object_link(note) %span.time= timeago(note.created_at) = will_paginate @notifications