[英]Notification bar in Ruby on Rails
I would like to create a Notification Bar similar to Facebook or StackExchange. 我想创建一个类似于Facebook或StackExchange的通知栏。
I want it to display notifications with numbers and a drop down panel with some information. 我希望它显示带有数字的通知以及带有一些信息的下拉面板。
Can someone provide an example or a tutorial on how to create that in Ruby on Rails or Javascript/jQuery? 有人可以提供一个示例或教程来说明如何在Ruby on Rails或Javascript / jQuery中创建它吗?
Thanks 谢谢
It's probably done as a two stage process: 它可能分为两个阶段完成:
The first part is simple, you just call a method on your association if you have a scope established: 第一部分很简单,如果已建立范围,则只需在关联上调用方法:
<%= link_to(@user.notifications.unread.count, user_notifications_path(@user), :class => 'notifications') %>
The next part involves patching together something with jQuery, perhaps like this: 下一部分涉及使用jQuery将某些东西修补在一起,也许像这样:
$('.notifications').click(function() {
$('#notifications').load(this.href);
return false;
});
You'll need to have a specific view that will render into that #notification
block. 您需要有一个特定的视图,该视图将渲染到该#notification
块中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.